11-23-2016 04:01 PM - edited 11-23-2016 04:04 PM
Hello,
Does anyone know how to obtain a 3D part geometry as a 3D Mesh (faces and vertices) using process simulate DotNet API? I would like to do some part geometry analysis using DotNet, however don't know how to obtain the 3D Mesh data through Process simulate DotNet API.
Thank you
Jinglin
Solved! Go to Solution.
11-25-2016 03:24 AM
Hi,
Check what information you can get from Approximation property of ITxGeometry interface. All geometry entities implement that interface. To get the entities of component you can load it in Entity Level or open it for modeling. Then call GetAllDescendant method using a TxTypeFilter with ITxGeometry type.
See here how to load Entity Level from the API
11-30-2016 02:58 PM
Hi DianaG,
Thank you for your replay!
I tried to select a component using the following code
ITxObject obj = TxApplication.ActiveSelection.GetItems()[0];
ITxGeometry geo = obj as ITxGeometry;
TxVector[] geoDataPoints = geo.Approximation.Points;
But ITxGeometry geo always gives me a NULL?
Where did I do wrong? Please advise, thanks!
Jinglin
12-01-2016 03:16 AM
Hi,
The ITxGeometry interface is implemented by the child elements of the component:
ITxComponent obj = TxApplication.ActiveSelection.GetItems()[0] as ITxComponent; if (!obj.IsOpenForModeling) { obj.SetModelingScope();//open it for modeling to load its child elements //you can also load entity level, it loads the child elements without opening the component for modeling } TxObjectList geoEntities = (obj as ITxObjectCollection).GetAllDescendants(new TxTypeFilter(typeof(ITxGeometry))); foreach(ITxGeometry geo in geoEntities) { .... }
12-01-2016 03:40 PM
DianaG,
Thank you for your reply again!
I am trying to visualize the geometry data using DotNet API. Basically I am trying to draw a line representing each point's normal direction. I created lines using TxLineCreationData, through debuging I confirmed the line data is created, however I can't visually see it in the viewer. Is there any switch need to be turned on to visually see the data or geometry (e.g., lines, boxes, arcs,etc.) created?
Thank you so much,
The following is my code:
TxObjectList geoEntities = (obj as ITxObjectCollection).GetAllDescendants(new TxTypeFilter(typeof(ITxGeometry)));
for (int j = 0; j < geoEntities.Count; ++j)
{
ITxGeometry geo = geoEntities[j] as ITxGeometry;
TxVector[] normals = geo.Approximation.Normals;
TxVector[] points = geo.Approximation.Points;
TxPrimitiveData[] primitives = geo.Approximation.Primitives;
TxLineCreationData[] lines = new TxLineCreationData[normals.Length];
for (int i = 0; i < normals.Length;++i)
{
TxVector startPoint = points[i];
TxVector endPoint = points[i] + normals[i] * 100.00;
TxVector zDirection = new TxVector(0,0,1);
TxVector orign = new TxVector(0,0,0);
TxTransformation absLoc = new TxTransformation(orign,zDirection);
string lineName = "line"+i.ToString();
lines[i] = new TxLineCreationData(lineName, absLoc, startPoint, endPoint);
lines[i].SetAsDisplay();
}
}
12-02-2016 02:50 AM
Hi
You need to create it in a txcomponent(Sorry VB.net)
Dim txcom As TxComponent = TxApplication.ActiveDocument.PhysicalRoot.CreateLocalComponent(TxLocalComponentCreationData1)
line = txcom.CreateLine(TxLineCreationData1)
Regards
12-02-2016 09:57 AM
Thank you,
Is that possible that I can creat a list of local components under physicalRoot?
Since I have 200 lines to creat. The object tree window pops up 200 line components after lines created. Is it possible to fold them together as a list (or a folder) in the Object tree window?
All the best,
Jinglin
12-02-2016 10:30 AM
Hi,
You can create all the lines under the same component, no need to create a new component for each line.
Here you can check how to save the component
12-02-2016 10:52 AM
Thank you, that works!
Watch Replays of Previous Topics