cancel
Showing results for 
Search instead for 
Did you mean: 

How to obtain a 3D part geometry as a 3D Mesh using Process simulate DotNet API?

Creator
Creator

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 

8 REPLIES

Re: How to obtain a 3D part geometry as a 3D Mesh using Process simulate DotNet API?

Siemens Legend Siemens Legend
Siemens Legend

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

 

 

Re: How to obtain a 3D part geometry as a 3D Mesh using Process simulate DotNet API?

Creator
Creator

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

Re: How to obtain a 3D part geometry as a 3D Mesh using Process simulate DotNet API?

Siemens Legend Siemens Legend
Siemens Legend

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)
            {
                ....
            }

Re: How to obtain a 3D part geometry as a 3D Mesh using Process simulate DotNet API?

Creator
Creator

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();
      }

}

 

 

 

Re: How to obtain a 3D part geometry as a 3D Mesh using Process simulate DotNet API?

Valued Contributor
Valued Contributor

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

Re: How to obtain a 3D part geometry as a 3D Mesh using Process simulate DotNet API?

Creator
Creator

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

Re: How to obtain a 3D part geometry as a 3D Mesh using Process simulate DotNet API?

Siemens Legend Siemens Legend
Siemens Legend

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

 

 

Re: How to obtain a 3D part geometry as a 3D Mesh using Process simulate DotNet API?

Creator
Creator

Thank you, that works!