[S8458] Script to obtain the coordinates of the vertices of parts

 

The following is an example of a script that obtains the coordinates of the vertices of parts.

app = designer.GetApplication()

# Get the model

objModel = app.GetCurrentModel()

# Initialize an empty string to store the results.

str_result = ""

# Get the part ID and process it in a loop.

for part_id in objModel.GetPartIDs():

   # Get part name

   PartN = objModel.GetPartName(part_id)

   # Get the vertex ID of the part and process it in a loop.

   for vertex_id in objModel.GetPart(part_id).GetVertexIDs():

       # Get the coordinates of the vertex

       vertex_point = objModel.GetVertexPosition(vertex_id)

       #Add the acquired coordinates to the list

       str_result += f"{PartN} : ({vertex_point.GetX()}, {vertex_point.GetY()}, {vertex_point.GetZ()})\n"

# Display results

print(str_result)

How to use script file

Use the JMAG Script Library after reading and agreeing to the following terms of use.