Locate all vertices of a part

Technical discussions
Post Reply
Chun Dao
Posts: 2
Joined: Tue Jun 16, 2020 5:08 am

Locate all vertices of a part

Post by Chun Dao »

Hello,

I'm a newbie with DGK. I want to ask you a question: How can I extract coordinates of all the vertices of an object from a STEP file and input the result to a text file with name separately for each vertex (like vertex1 (3; 4; 5), vertex2 (1; 2; 3)?

I hope to receive your answers soon.

Chun

Mike_Rost
Posts: 3
Joined: Fri Sep 27, 2013 10:23 am

Re: Locate all vertices of a part

Post by Mike_Rost »

Try IBRepShape_DG.GetSubShapes().

Code: Select all

	    IGeometry_DG iGeom = theEntity.GetGeometry();
            IBRepGeometry_DG iBrepGeom = iGeom as IBRepGeometry_DG;
            IBRepShape_DG iShape = iBrepGeom.GetShape();

            IShapeArray_DG vertices = iShape.GetSubShapes(ShapeType_DG.eShTypeVertexDG);

            int n = vertices.GetCount();
	    double x,y,z;
            for (int i = 0; i < n; i++)
            {
                IBRepShape_DG shapeVert = vertices.GetAt(i);
                IBRepVertex_DG vert = shapeVert as IBRepVertex_DG;
                vert.GetPosition(out x, out y, out z)
                //... do something
            }
I did not compile that. Search for GetSubShapes in samples for a live example.
Regards

Chun Dao
Posts: 2
Joined: Tue Jun 16, 2020 5:08 am

Re: Locate all vertices of a part

Post by Chun Dao »

Thank you.
I see it working

Post Reply