I needed a quick way to suppress and unsuppress mates and joints, or constraints and joints in assembly files, so I wrote a quick utility to do just that. Below is an animated GIF showing the code in action:
The iLogic code checks that it is in an assembly file, then presents the user with an “input radio box” as shown below, these are a quick easy way to get information from the user, but they do have their downsides. “Input radio boxes” return a Boolean (True/False) result. The issue here, is that if the user selects nothing (or exits), the code will run anyway. In this instance, it will automatically select “True”, this will unsupress all mates and joints. This is perfectly acceptable for my use case, but you may want to use an input list box, as you have more control, and more options (see example here).
Once the user has made their selection, the code iterates through the assembly and either suppresses or unsuppresses the constrains and joints as specified, in additon to counting them, the results of which are displayed in a message box.
Here’s the iLogic Code:
'iLogic code by Clint Brown @ClintBrown3D 'Code originally posted at https://clintbrown.co.uk/ilogic-toggle-mate-amp-joint-suppression oDoc = ThisDoc.ModelDocument 'Check that this is an Assembly If oDoc.DocumentType = kPartDocumentObject Then: MessageBox.Show("This only works in Assemblies", "@ClintBrown3D"): Return: End If x = InputRadioBox("Manage Mates and Joints", "Suppress Constrains and Joints", "Unsuppress Constrains and Joints", booleanParam, Title := "Unofficial Inventor") Dim oAssDoc As AssemblyDocument oAssDoc = ThisApplication.ActiveDocument Dim oConstraint As AssemblyConstraint Dim oJoint As AssemblyJoint i = 0 For Each oConstraint In oAssDoc.ComponentDefinition.Constraints If x = "True" Then : oConstraint.Suppressed = x: i = i + 1 : z= "Supressed ": End If If x = "False" Then: oConstraint.Suppressed = x :i = i + 1: z= "Unsupressed ":End If Next j = 0 For Each oJoint In oAssDoc.ComponentDefinition.Joints If x = "True" Then : oJoint.Suppressed = x: j = j + 1 : End If If x = "False" Then: oJoint.Suppressed = x :j = j + 1 : End If Next MessageBox.Show(z & i & " Constraints & " & j & " Joints" , "Unofficial Inventor")
This version of the code was briefly tested in Inventor 2021.
As always, please test all iLogic code extensively on non-production files. Do not use any code in a production environment until YOU have thoroughly tested it and have verified that it works as expected. Always back up any data before running any experimental code. You are ultimately responsible for any iLogic code that you run, so make sure you test it thoroughly!