How to export both free points (datum points) and sketch points to a csv file?

Rohith Patchigolla
Rohith Patchigolla Member, Moderator, Employee Posts: 216
100 Comments 25 Answers Second Anniversary 25 Likes
✭✭✭✭

Answers

  • Rohith Patchigolla
    Rohith Patchigolla Member, Moderator, Employee Posts: 216
    100 Comments 25 Answers Second Anniversary 25 Likes
    ✭✭✭✭

    The below script (tested in 24R2), can export both the free points and sketch points to a csv.

    outputDialog=SaveFileDialog()
    
    outputDialog.Filter='Datum Point File (*.csv)|*.csv'
    outputDialog.Show()
    outputfile=outputDialog.FileName
    
    #Get all the datum points in the current file
    allDatumPoints=GetRootPart().GetDescendants[IDatumPoint]()
    
    #Loop through all the points and save the x,y,z coordinates to file.
    with open(outputfile,'w+') as outFile:
        for dPoint in list(allDatumPoints):
            X=dPoint.Position.X
            Y=dPoint.Position.Y
            Z=dPoint.Position.Z
            outFile.write(str(X)+','+str(Y)+','+str(Z)+'\n')
        for point in GetRootPart().Curves:
            if point.GetName() == "Point":
                pointCoordinates = point.Shape.EndPoint
                outFile.write(str(pointCoordinates[0])+','+str(pointCoordinates[1])+','+str(pointCoordinates[2])+'\n')