How to create Function Expressions (force and torque) from a selected joint?

Gabriel Messager
Gabriel Messager Member, Employee Posts: 63
5 Answers Second Anniversary 10 Comments 5 Likes
✭✭✭✭

From a joint I select in the Mechanical tree, I want to create automatically 6 Function Expressions to post process joint tensor in the global coordinate system.

Tagged:

Answers

  • Gabriel Messager
    Gabriel Messager Member, Employee Posts: 63
    5 Answers Second Anniversary 10 Comments 5 Likes
    ✭✭✭✭
    edited March 18
    analysis = Model.Analyses[0]
    joint = Tree.FirstActiveObject
    group_FE = []
    group_CR = []
    if isinstance(joint, Ansys.ACT.Automation.Mechanical.Connections.Joint):
        for comp in ["FX","FY","FZ","TX","TY","TZ"]:
            newfunction = analysis.CreateLoadObject("FunctionExpression","ANSYSMotion")
            newfunction.Properties['Definition/FunctionExpression'].Value = comp + r'(p1,p2)'
            newfunction.Caption = joint.Name + "_" + comp
            table = newfunction.Properties.GetByName("FunctionArgument")
            for i, suffix in enumerate(["/ActionMarker", "/BaseMarker"]):
                table.AddRow()
                table.Properties.GetByName("XData").Value = "p" + str(i+1)
                table.Properties.GetByName("YData").Value = str(joint.ObjectId) + suffix
                table.SaveActiveRow()
            newfunction.NotifyChange()
            group_FE.append(newfunction)
    
            custom_result = analysis.CreatePostObject("CustomResult","ANSYSMotion")
            custom_result.Properties['Definition/Type/FunctionExpression'].Value = str(newfunction.ObjectId)
            custom_result.Caption = "CR_" + joint.Name + "_" + comp
            group_CR.append(custom_result)
    
        grouping_folder = Tree.Group(group_FE)
        grouping_folder.Name = joint.Name
        grouping_folder = Tree.Group(group_CR)
        grouping_folder.Name = "CR_" + joint.Name
    else:
        print("not joint")