|
- #region 模型点击触发事件20160704增加选中模型触发事件
- [Plugin("Form1.MyToolPlugin", "ADSK",
- DisplayName = "MyToolPlugin",
- ToolTip = "Primitive Select Custom Tool Plugin")]
- public class MyToolPlugin : ToolPlugin
- {
- public override bool MouseDown(Autodesk.Navisworks.Api.View view, KeyModifiers modifiers, ushort button, int x, int y, double timeOffset)
- {
- // Very simple primitive additive select. Doesn't follow Windows 'standard' of 'mouse down to start select, mouse up if you really mean it'
- PickItemResult result = view.PickItemFromPoint(x, y);
- if (result != null)
- {
- Autodesk.Navisworks.Api.Application.ActiveDocument.CurrentSelection.Clear();
- Autodesk.Navisworks.Api.Application.ActiveDocument.CurrentSelection.Add(result.ModelItem);
- getpro();//20160705绑定选中模型的属性
- return true;
- }
- // As you can only have one tool plugin active, it isn't actually possible
- // to pass control to another handler at this time. However, good practice
- // to indicate whether you handled the call.
- return false;
- }
- }
- public static void getpro()
- {
- gform.tableLayoutPanel1.ColumnStyles[2].Width = 30;//点击选中模型显示属性信息
- //属性信息加载
- //验证模型
- List<propertys> list = new List<propertys>();
- //gform.dataGridView1.DataSource = list;
- string strs="";//存储text 过滤相同的
- if (Autodesk.Navisworks.Api.Application.ActiveDocument != null &&
- !Autodesk.Navisworks.Api.Application.ActiveDocument.IsClear)
- {
- //this.vGridControl1.Rows.Clear();
- // 获取选中的相关的模型信息
- foreach (ModelItem item in Autodesk.Navisworks.Api.Application.ActiveDocument.CurrentSelection.SelectedItems)
- {
- //获取想的模型属性信息
- string s = item.ClassName;
- foreach (PropertyCategory category in item.PropertyCategories)
- {
- foreach (DataProperty control in category.Properties)
- {
- var itemValue = control.Value;
- string text = control.DisplayName +"/"+ control.Name;
- string valueInfo;
- switch (itemValue.DataType)
- {
- case VariantDataType.Boolean:
- valueInfo = itemValue.ToBoolean().ToString();
- break;
- case VariantDataType.DateTime:
- valueInfo = itemValue.ToDateTime().ToString();
- 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;
- }
- propertys ps = new propertys();
- ps.Name = text;
-
- ps.Value = valueInfo;
- if (strs.IndexOf(text)<0)
- {
- list.Add(ps);
- }
- strs += text + ",";
-
-
- }
- }
- }
- }
- gform.dataGridView1.DataSource = list;
- }
- #endregion
复制代码
请问,我抓取的nwd模型文件,怎么获取不到id和名称这些属性 |
|