How can I change a joint's reference coordinate system through scripting?

Options
Pernelle Marone-Hitz
Pernelle Marone-Hitz Member, Moderator, Employee Posts: 804
First Comment First Anniversary Ansys Employee Solution Developer Community of Practice Member
edited June 2023 in Structures

How can I modify the orientation of a joint's coordinate system through Mechanical scripting?

Tagged:

Answers

  • Pernelle Marone-Hitz
    Pernelle Marone-Hitz Member, Moderator, Employee Posts: 804
    First Comment First Anniversary Ansys Employee Solution Developer Community of Practice Member
    Answer ✓
    Options

    Here is an example of code to change the primary axis and its geometric selection:

        # reference connections
        connections = ExtAPI.DataModel.Project.Model.Connections
    
        # get first joint inside connections
        my_joint=connections.GetChildren(DataModelObjectCategory.Joint,True)[0]
    
        # access the joint's reference coordinate system
        jointCS = my_joint.ReferenceCoordinateSystem
    
        # set joint's principal axis to global X axis
        jointCS.PrimaryAxis=CoordinateSystemAxisType.PositiveXAxis
    
        # obtain id of a face selected in Mechanical:
        currentSel=ExtAPI.SelectionManager.CurrentSelection
    
        # create a temporary selection
        tempSel=ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities)
        tempSel.Ids=currentSel.Ids
    
        # change joint's primary axis geometric selection to the selected face in Mechanical :
        jointCS.PrimaryAxisLocation=tempSel