
Several months back, I created an iLogic routine that will delete all mates & joints in an assembly, and ground all of the components. I was asked if I could do something similar for a client. The requirement was to supress all mates and joints, then ground all of the components in the assembly. The second part of the request was the ability to un-ground and unsupress all of the constraints/joints.
Turns out that this was very easy to do, but the one consideration is that when un-grounding everything in the assembly, the first component in the assembly will be ungrounded. To fix this, I added a few lines of code at the end of the rule to find the first instance in the browser and to ground it.
Here’s a GIF showing the code in action

Here’s the code:
'Code by @ClintBrown3D originally posted here: --> https://clintbrown.co.uk/ilogic-supress-constraints-amp-ground-all-components 'Some code here was borrowed from Curtis, see http://inventortrenches.blogspot.com/2012/05/working-with-unconstrained-imported.html 'This version of the code is adapted from a sample first published here: https://clintbrown.co.uk/ilogic-delete-all-mates-joints-ground Dim oAssDoc As AssemblyDocument oAssDoc = ThisApplication.ActiveDocument Dim oConstraint As AssemblyConstraint Dim oJoint As AssemblyJoint qGround = True qGround = InputRadioBox("Prompt", "Suppress Constrains + Ground all", "Unsupress Constrains + Un-Ground all", booleanParam, Title := "Unofficial Inventor ") i = 0 For Each oConstraint In oAssDoc.ComponentDefinition.Constraints oConstraint.Suppressed = qGround i = i + 1 Next ii = 0 For Each oJoint In oAssDoc.ComponentDefinition.Joints oJoint.Suppressed = qGround ii = ii + 1 Next 'get the active assembly Dim oAsmCompDef As AssemblyComponentDefinition oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition 'set the Master LOD active Dim oLODRep As LevelOfDetailRepresentation oLODRep = oAsmCompDef.RepresentationsManager.LevelOfDetailRepresentations.Item("Master") oLODRep.Activate 'Iterate through all of the top level occurrences Dim oOccurrence As ComponentOccurrence For Each oOccurrence In oAsmCompDef.Occurrences If oOccurrence.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then 'Iterate through all of the 2nd level occurrences Dim oSub1Occ As ComponentOccurrence For Each oSub1Occ In oOccurrence.SubOccurrences 'ground everything in the 2nd level oSub1Occ.Grounded = qGround If oSub1Occ.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then 'Iterate through all of the 3nd level occurrences Dim oSub2Occ As ComponentOccurrence For Each oSub2Occ In oSub1Occ.SubOccurrences 'ground everything in the 3rd level oSub2Occ.Grounded = qGround Next Else End If Next Else End If 'ground everything in the top level oOccurrence.Grounded = qGround Next 'Ground the first node Dim doc = ThisDoc.Document Dim oDef As AssemblyComponentDefinition = doc.ComponentDefinition Dim oCompOcc As Inventor.ComponentOccurrence Dim oNames As New ArrayList For Each oCompOcc In oDef.Occurrences GetOccName = oCompOcc.Name oNames.Add(GetOccName) Next Dim bob As String = oNames(0) For Each oCompOcc In oDef.Occurrences If oCompOcc.Name = bob Then oCompOcc.Grounded = True End If Next MessageBox.Show("Successfully processed " & i & " constraints " & ii & " joints", "iLogic - @ClintBrown3D")
Notes:
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!