I have grouped Bonded contacts as follows:
I want to use scripting to change their contact types into Fixed joints, how do I do that ?
Here is an example of script that suppresses all the contacts of the group "Contacts_to_change" and that creates another group with Fixed Joints contacts scoped with corresponding source/target faces.
See example code below:
bonded_contact_group=DataModel.GetObjectsByName("Contacts_to_change")[0] my_bonded_contact_source_faces=[] my_bonded_contact_target_faces=[] fixed_joint_group=Model.Connections.AddConnectionGroup() fixed_joint_group.Name="Contacts_changed" for contact in bounded_contact_group.Children: my_bonded_contact_source_face=contact.SourceLocation my_bonded_contact_target_face=contact.TargetLocation my_bonded_contact_source_faces.append(contact.SourceLocation) my_bonded_contact_target_faces.append(contact.TargetLocation) my_fixed_joint=fixed_joint_group.AddJoint() my_fixed_joint.ReferenceLocation=my_bounded_contact_source_face my_fixed_joint.MobileLocation=my_bounded_contact_target_face contact.Suppressed = True
We can check that the contacts have been converted:
You may also want to create another script that reverses the action:
bounded_contact_group=DataModel.GetObjectsByName("Contacts_to_change")[0] for contact in bounded_contact_group.Children: contact.Suppressed = False fixed_joint_group=DataModel.GetObjectsByName("Contacts_changed")[0] fixed_joint_group.Delete()