我正在尝试导出 Navis 中选定对象的顶点、面和颜色。经过一番研究,我发现我们可以使用 Navisworks 提供的 COM API 来做到这一点。我使用 getprimitives 来找到三角形。看起来如下。
'using Autodesk.Navisworks.Api;
using Autodesk.Navisworks.Api.Plugins;
using ComBridge = Autodesk.Navisworks.Api.ComApi.ComApiBridge;
using COMApi = Autodesk.Navisworks.Api.Interop.ComApi;
#region InwSimplePrimitivesCB Class
class CallbackGeomListener : COMApi.InwSimplePrimitivesCB
{
public void Line(COMApi.InwSimpleVertex v1,
COMApi.InwSimpleVertex v2)
{
// do your work
}
public void Point(COMApi.InwSimpleVertex v1)
{
// do your work
}
public void SnapPoint(COMApi.InwSimpleVertex v1)
{
// do your work
}
public void Triangle(COMApi.InwSimpleVertex v1,
COMApi.InwSimpleVertex v2,
COMApi.InwSimpleVertex v3)
{
// do your work
}
}
#endregion
#region NW Plugin
[PluginAttribute("Test","ADSK",DisplayName= "Test")]
[AddInPluginAttribute(AddInLocation.AddIn)]
public class Class1:AddInPlugin
{
public override int Execute(params string[] parameters)
{
// get the current selection
ModelItemCollection oModelColl =
Autodesk.Navisworks.Api.Application.
ActiveDocument.CurrentSelection.SelectedItems;
//convert to COM selection
COMApi.InwOpState oState = ComBridge.State;
COMApi.InwOpSelection oSel =
ComBridge.ToInwOpSelection(oModelColl);
// create the callback object
CallbackGeomListener callbkListener =
new CallbackGeomListener();
foreach (COMApi.InwOaPath3 path in oSel.Paths())
{
foreach (COMApi.InwOaFragment3 frag in path.Fragments())
{
// generate the primitives
frag.GenerateSimplePrimitives(
COMApi.nwEVertexProperty.eNORMAL,
callbkListener);
}
}
return 0;
}
}
#endregion
'
这里的问题是我无法找到面,我确实使用三角形方法获得了顶点。如果有人知道如何找到物体的面孔和颜色,请告诉我。