Community
Navisworks API
Welcome to Autodesk’s Navisworks API Forums. Share your knowledge, ask questions, and explore popular Navisworks API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Get global coordinates of the points of the triangle

2 REPLIES 2
Reply
Message 1 of 3
Evgueny
1473 Views, 2 Replies

Get global coordinates of the points of the triangle

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.

2 REPLIES 2
Message 2 of 3
admin
in reply to: Evgueny

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.

Message 3 of 3
xiaodong_liang
in reply to: Evgueny

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


Autodesk Design & Make Report