Page 1 of 1

Locate all vertices of a part

Posted: Tue Jun 16, 2020 5:11 am
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

Re: Locate all vertices of a part

Posted: Wed Jun 17, 2020 7:54 am
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

Re: Locate all vertices of a part

Posted: Thu Jun 18, 2020 3:56 am
by Chun Dao
Thank you.
I see it working