Help me please.
How to get the global coordinates of the points of the triangle?
using the 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) { Array array_v = (Array)(object)v1.coord; float x = (float)array_v.GetValue(1); float y = (float)array_v.GetValue(2); float z = (float)array_v.GetValue(3); ABasicPlugin.TriangleLIST.Add(x); ABasicPlugin.TriangleLIST.Add(y); ABasicPlugin.TriangleLIST.Add(z); array_v = (Array)(object)v2.coord; float x = (float)array_v.GetValue(1); float y = (float)array_v.GetValue(2); float z = (float)array_v.GetValue(3); ABasicPlugin.TriangleLIST.Add(x); ABasicPlugin.TriangleLIST.Add(y); ABasicPlugin.TriangleLIST.Add(z); array_v = (Array)(object)v3.coord; float x = (float)array_v.GetValue(1); float y = (float)array_v.GetValue(2); float z = (float)array_v.GetValue(3); ABasicPlugin.TriangleLIST.Add(x); ABasicPlugin.TriangleLIST.Add(y); ABasicPlugin.TriangleLIST.Add(z); } }
and function
ModelItemCollection oModelColl = Autodesk.Navisworks.Api.Application.ActiveDocument.CurrentSelection.SelectedItems; COMApi.InwOpState oState = ComBridge.State; COMApi.InwOpSelection oSel = ComBridge.ToInwOpSelection(oModelColl); CallbackGeomListener callbkListener = new CallbackGeomListener(); foreach (COMApi.InwOaPath3 path in oSel.Paths()) { COMApi.InwLBox3f B3f = path.GetBoundingBox(); // центральная точка примитива foreach (COMApi.InwOaFragment3 frag in path.Fragments()) { TriangleLIST = new ArrayList(); frag.GenerateSimplePrimitives(COMApi.nwEVertexProperty.eNORMAL, callbkListener); } }
I get the point of local.
An easy way of converting the local space (vertex positions) to world space (what you want) is to add the bounding box center of the geometry you're pulling vertex information from.
In your case, you already have the line here:
COMApi.InwLBox3f B3f = path.GetBoundingBox();
All you really need to do is loop over the triangles and add the points together :).
In my own implementation I use the C# API for this, item.Geometry.BoundingBox.Center. But I'm sure it can't be that hard to grab the Center XYZ values from a InwLBox3f.
Hi Evgueny,
I have not tried what johan.rensenbrink suggetsed, but the forum post I answered might be helpful
http://forums.autodesk.com/t5/Navisworks-API/Convert-LCS-to-WCS-with-COM-api/td-p/4840957