Navisworks二次开发——图元属性获取
try
{
//当前文档
Document doc = Application.ActiveDocument;//application是运行了之后自动提供的
if (Application.ActiveDocument != null &&
!Application.ActiveDocument.IsClear)
{
foreach (ModelItem item in Autodesk.Navisworks.Api.Application.ActiveDocument.CurrentSelection.SelectedItems)
{
foreach (var cat in item.PropertyCategories)
{
if (cat.DisplayName == "元素 ID")
{
foreach (var prop in cat.Properties)
{
System.Windows.Forms.MessageBox.Show(prop.DisplayName);
if (prop.DisplayName == "值")
{
System.Windows.Forms.MessageBox.Show(prop.Value.ToString());
}
}
}
}
}
}
return 0;
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);//输出显示异常信息
return 0;
}