script to automatically export coordinate systems in DesignModeler
Hello all,
There are over 100 local coordinate systems, but I don't want to manually export them out. Is there any script that could write all the coordinate systems (each has one center and 3 axes) into a file? Thanks!
Regards,
Rahul
Comments
-
posted the mechanical solution before realizing it was dm.
0 -
You can set the property of the CS to be exported and then either take the .agdb file into mechanical or SC/Disco. This is a script to export the CS info once in SC/Disco. The DM scripting is not very full as of 24.1 releases, so it will be hard to export this and likely the API will not be supported if you find a way.
import csv
Root = GetRootPart()
FilePath=r'C:\Users\mthompso\MyData\DeleteThis\CsData.csv'
DirNames = ["X","Y","Z"]
AxisNames = [[AA+ " Axis: "+A for A in DirNames] for AA in DirNames]
Header = ["Name"]+AxisNames[0]+AxisNames[1]+AxisNames[2]+["Origin: "+A for A in DirNames]
with open(FilePath, "wb") as csv_file:
writer = csv.writer(csv_file, delimiter=',')
writer.writerow(Header)
for CS in Root.CoordinateSystems:
AxisX = list(CS.Frame.AxisX.Direction)
AxisY = list(CS.Frame.AxisY.Direction)
AxisZ = list(CS.Frame.AxisZ.Direction)
Orig = list(CS.Frame.Origin)
Data = [CS.GetName()]+Orig+AxisX+AxisY+AxisZ
writer.writerow(Data)1 -
Thank you, Mike!
1