乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      Navisworks 2014 Api 簡(jiǎn)單的使用

       _鎏_ 2015-09-08

      初次接觸Navisworks Api  .NET 的二次開發(fā).主要是研究了一下。關(guān)于NavisWorks 結(jié)構(gòu)樹的加載.

      復(fù)制代碼
           void LoadModel()
              {
                  //清空當(dāng)前的結(jié)構(gòu)樹信息
                  treeView1.Nodes.Clear();
                  //當(dāng)前加載的模型
                  Document doc = Autodesk.Navisworks.Api.Application.ActiveDocument;
                  
                  //循環(huán)現(xiàn)有模型
                  foreach (var documentModel in doc.Models)
                  {
                    
                      var modelItemList = documentModel.RootItem.Descendants;
                      Model model = documentModel;
                      var modelItems = modelItemList.Where(o => o.Parent == model.RootItem);
                 
                      if (modelItems.Any())
                      {
                          TreeNode cNode;
                          foreach (var quItem in modelItems)
                          {
                               cNode = new TreeNode(quItem.DisplayName);
                              cNode.Tag = quItem;
                             // cNode.Text = quItem.DisplayName;//判斷名稱
                              treeView1.Nodes.Add(cNode);
                              if (quItem.Children.Any())
                              {
                                  LoadChild(quItem.Children, quItem, cNode);   
                              }
                 
                            
                          }
                      }
                      
                  }
        
              }
      
              /// <summary>
              /// 遞歸判斷結(jié)構(gòu)樹信息
              /// </summary>
              /// <param name="modelItemEnumerableCollection">數(shù)據(jù)源信息</param>
              /// <param name="parentItem">父級(jí)節(jié)點(diǎn)信息</param>
              /// <param name="pNode">子節(jié)點(diǎn)信息</param>
              private void LoadChild(IEnumerable<ModelItem> modelItemEnumerableCollection, ModelItem parentItem, TreeNode pNode)
              {
                  var query = modelItemEnumerableCollection.Where(o => o.Parent == parentItem);
                  if (query.Count()>0)
                  {
                      foreach (var quItem in query)
                      {
                          TreeNode chNode = new TreeNode(quItem.DisplayName);
                          chNode.Tag = quItem;
                          pNode.Nodes.Add(chNode);
                          if (quItem.Children.Any())
                          {
                              LoadChild(quItem.Children, quItem, chNode);
                          }
                        
                      }
                  }
              }
      復(fù)制代碼

      TreeView Node 選中事件

      復(fù)制代碼
             void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
              {
                  TreeNode node = e.Node;
                  if (node != null)
                  {
                      ModelItem oCurrentNode = (ModelItem)node.Tag;
                      propertyGrid1.SelectedObject = oCurrentNode;
                      if (oCurrentNode != null)
                      {
      
                          //設(shè)置選擇集合
                          ModelItemCollection oMC = new ModelItemCollection();
                          oMC.Add(oCurrentNode);
                          Document oDoc = view.ViewControl.DocumentControl.Document;
                          //設(shè)置選中
                          oDoc.CurrentSelection.CopyFrom(oMC);
                      }
                }
              }
      復(fù)制代碼

      模型加載窗口:

      復(fù)制代碼
          public partial class FrmModelView : DevExpress.XtraEditors.XtraForm
          {
              public ViewControl ViewControl;
              public FrmModelView()
              {
                  InitializeComponent();
                  if (this.components == null)
                      this.components = new Container();
                  //初始化Document控件
                  DocumentControl document = new DocumentControl(this.components);
                  document.Document.SetGraduatedBackground(Autodesk.Navisworks.Api.Color.FromByteRGB(176,196,222),Autodesk.Navisworks.Api.Color.FromByteRGB(176,196,166));
                  //初始化View控件  并添加Document控件
                  ViewControl = new ViewControl();
                  ViewControl.DocumentControl = document;
                  ViewControl.BackColor = System.Drawing.Color.LightSteelBlue;
                  ViewControl.Dock = DockStyle.Fill;
                  ViewControl.Name = "viewControl";
                  this.Controls.Add(ViewControl);
              }
          }
      復(fù)制代碼

      模型選擇事件:

      復(fù)制代碼
              #region 模型選擇事件
      
              private void CurrentSelection_Changed(object sender, EventArgs e)
              {
                  try
                  {
                      Document doc = (Document)sender;
                      if (doc != null)
                      {
                          var item = doc.CurrentSelection.SelectedItems[0];
                          if (item != null)
                          {
      
                              TreeNode tnRet = null;
                              foreach (TreeNode tn in treeView1.Nodes)
                              {
                                  tnRet = FindNode(tn, item.DisplayName);
                                  if (tnRet != null)
                                      break;
                              }
                              if (tnRet != null)
                              {
                                  if (oldNode != null)
                                      oldNode.BackColor = Color.White;
                                  tnRet.BackColor = Color.YellowGreen;
                                  treeView1.SelectedNode = tnRet;
                                  oldNode = tnRet;
                                  GetProperty();
                              }
                          }
                      }
                  }
                  catch (Exception exception)
                  {
                      Console.WriteLine(exception);
                  }
              }
      
              #endregion
      復(fù)制代碼

      模型的屬性加載:

      復(fù)制代碼
        #region 屬性信息加載
      
              void GetProperty()
              {
                  //驗(yàn)證模型
                  if (Autodesk.Navisworks.Api.Application.ActiveDocument != null &&
                      !Autodesk.Navisworks.Api.Application.ActiveDocument.IsClear)
                  {
                    
                      this.vGridControl1.Rows.Clear();
                      // 獲取選中的相關(guān)的模型信息
                      foreach (ModelItem item in Autodesk.Navisworks.Api.Application.ActiveDocument.CurrentSelection.SelectedItems)
                      {
                    
                          //獲取想的模型屬性信息
                          foreach (PropertyCategory category in item.PropertyCategories)
                          {
                              CategoryRow  categoryRow=new CategoryRow(category.DisplayName);
                              foreach (var control in category.Properties)
                              {
                                  EditorRow row1 = new EditorRow();
                                  row1.Properties.FieldName = "Value";
                                  row1.Properties.Caption = control.DisplayName;
                                  var itemValue = control.Value;
                                  string valueInfo;
                                  switch (itemValue.DataType)
                                  {
                                      case VariantDataType.Boolean:
                                          valueInfo = itemValue.ToBoolean().ToString();
                                          break;
                                      case VariantDataType.DateTime:
                                          valueInfo = itemValue.ToDateTime().ToString(CultureInfo.InvariantCulture);
                                          break;
                                      case VariantDataType.DisplayString:
                                          valueInfo = itemValue.ToDisplayString();
                                          break;
                                      case VariantDataType.Double:
                                          valueInfo = itemValue.ToDouble().ToString();
                                          break;
                                      case VariantDataType.DoubleAngle:
                                          valueInfo = itemValue.ToDoubleAngle().ToString();
                                          break;
                                      case VariantDataType.DoubleArea:
                                          valueInfo = itemValue.ToDoubleArea().ToString();
                                          break;
                                      case VariantDataType.DoubleLength:
                                          valueInfo = itemValue.ToDoubleLength().ToString();
                                          break;
                                      case VariantDataType.DoubleVolume:
                                          valueInfo = itemValue.ToDoubleVolume().ToString();
                                          break;
                                      case VariantDataType.IdentifierString:
                                          valueInfo = itemValue.ToIdentifierString();
                                          break;
                                      case VariantDataType.Int32:
                                          valueInfo = itemValue.ToInt32().ToString();
                                          break;
                                      default:
                                          valueInfo = itemValue.ToString();
                                          break;
                                  }
                                  row1.Properties.Value = valueInfo;
                                  
                                  categoryRow.ChildRows.Add(row1);
                              }
                              this.vGridControl1.Rows.Add(categoryRow);
                          }
                      }
                  }
              }
              #endregion
      復(fù)制代碼

      最終效果:

      主要是剛接觸這個(gè).不懂 只是自己在這寫的。如果那位網(wǎng)友有更好的解決方案。請(qǐng)告訴我.謝謝哈

       

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶 評(píng)論公約