How to group joint results in the same groups we create in connections definition ?

Jean
Jean Member Posts: 30
10 Comments 5 Likes First Anniversary Name Dropper
**

Hi,

I create a code in order the create joint results (force and moment) for each joint in the model. All the results are store in the same group.

def def_JointExport(analysis,nom="Liaisons",temps=[]):
        numberAnalysis=Tree.GetPathToFirstActiveObject()
        nameAnalysis=numberAnalysis[numberAnalysis.find('[')+1:numberAnalysis.find(']')]
        solution = ExtAPI.DataModel.Project.Model.Analyses[int(nameAnalysis)].Solution
        connections = ExtAPI.DataModel.Project.Model.Connections

        strForceUnit = ExtAPI.DataModel.CurrentUnitFromQuantityName("Force")
        strMomentUnit = ExtAPI.DataModel.CurrentUnitFromQuantityName("Moment")
        strLengthUnit = ExtAPI.DataModel.CurrentUnitFromQuantityName("Length")
        strVelocityUnit = ExtAPI.DataModel.CurrentUnitFromQuantityName("Velocity")

        joints_temp = connections.GetChildren(DataModelObjectCategory.Joint,True)
        joints = [joint for joint in joints_temp if joint.Suppressed == False and len(joint.MobileLocation.Ids) != 0 and len(joint.ReferenceLocation.Ids) != 0]

        liste_dossier = solution.GetChildren(DataModelObjectCategory.TreeGroupingFolder, True)

        if len(temps) == 0:
            temps = analysis.StepsEndTime

        # Suppresion du dossier DDC si deja existant
        for dossier in liste_dossier:
            if dossier.Name == "{}".format(nom):
                dossier.DeleteTreeGroupAndChildren()

        # Create a joint probe for each joint not already having a result probe
        resgr=[]
        cpt = 0
        with Transaction(suspendClicks=True):
            for joint in joints:
                if joint.Suppressed == False:
                    cpt = cpt + 1
                    joint_probe = solution.AddJointProbe()
                    joint_probe.BoundaryConditionSelection = joint
                    joint_probe.Name = "Liaison_Pdt{}_F_{}_{}".format(str(temps[0]),str(joint.Type), joint.Name)
                    joint_probe.DisplayTime = Quantity(str(temps[0]) + ' [sec]')
                    #joint_probe.RenameBasedOnDefinition()
                    resgr.append(joint_probe)
                    joint_probe = solution.AddJointProbe()
                    joint_probe.BoundaryConditionSelection = joint
                    try:
                        joint_probe.ResultType = ProbeResultType.MomentReaction
                        joint_probe.Name = "Liaison_Pdt{}_M_{}_{}".format(str(temps[0]),str(joint.Type), joint.Name)
                        joint_probe.DisplayTime = Quantity(str(temps[0]) + ' [sec]')
                        #joint_probe.RenameBasedOnDefinition()
                        resgr.append(joint_probe)
                    except:
                        joint_probe.ResultType = ProbeResultType.FrictionMomentProbe
                        joint_probe.Name = "Liaison_Pdt{}_M_{}_{}".format(str(temps[0]),str(joint.Type), joint.Name)
                        joint_probe.DisplayTime = Quantity(str(temps[0]) + ' [sec]')
                        #joint_probe.RenameBasedOnDefinition()
                        resgr.append(joint_probe)
                        joint_probe = solution.AddJointProbe()
                        joint_probe.BoundaryConditionSelection = joint
                        joint_probe.ResultType = ProbeResultType.RotationProbe
                        joint_probe.Name = "Liaison_Pdt{}_M_{}_{}".format(str(temps[0]),str(joint.Type), joint.Name)
                        joint_probe.DisplayTime = Quantity(str(temps[0]) + ' [sec]')
                        #joint_probe.RenameBasedOnDefinition()
                        resgr.append(joint_probe)
            ExtAPI.DataModel.Tree.Refresh()

        if cpt != 0:
            dossier_joints = ExtAPI.DataModel.Tree.Group(resgr)
            dossier_joints.Name = "{}".format(nom)

        solution.EvaluateAllResults()

For now, I only get one folder with all results inside.

But in case I have multiple folders in the connection definition, is there a way to group joint results in the same groups ?

Here an example of folders :

Regards,
Jean

Answers

  • James Derrick
    James Derrick Administrator, Employee Posts: 292
    Ancient Membership 100 Comments 100 Likes 25 Answers
    admin

    Hi Jean, thanks for your question, I am tagging the @AKD-Scripting-Team who should be able to help.

  • Ayush Kumar
    Ayush Kumar Member, Moderator, Employee Posts: 472
    100 Answers 250 Likes 100 Comments Second Anniversary
    ✭✭✭✭

    @Jean there isn't a direct API to do this. You need to loop over all the Joint results fetch their Boundary Condition and collect the ones that belong to a group together in a list and then create a Group.

    joint.BoundaryConditionSelection
    
    Tree.Group(joints)