script to automatically export coordinate systems in DesignModeler

RK Member, Employee Posts: 11
Name Dropper First Comment

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!



  • M
    M Member, Employee Posts: 230
    First Comment First Anniversary Ansys Employee Solution Developer Community of Practice Member
    edited May 2

    posted the mechanical solution before realizing it was dm.

  • Mike.Thompson
    Mike.Thompson Member, Employee Posts: 279
    First Anniversary First Comment 5 Likes Ansys Employee
    edited May 6

    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()
    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=',')
    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

  • RK
    RK Member, Employee Posts: 11
    Name Dropper First Comment

    Thank you, Mike!