iLogic – Delete all Mates/Joints & Ground

@ClintBrown3D Autodesk Inventor 14

Have you ever wanted to delete all of the constraints in an assembly, and then ground all components? Well look no further, the iLogic code in this blog post does exactly that.

You may be wondering why you would want to do this, well the answer is simple. Inventor calculates each relationship between parts (especially when adding or moving components). In a large static assembly (no moving parts), the file performance will improve, if all of the components are grounded, as opposed to having several constraints applied to them.

I put this code together based on some of the Autodesk Inventor API samples, as well as with some code borrowed from Curtis Waguespack’s blog post on unconstrained geometry. I’ve also updated the code to include assembly joints as well.

The animated GIF below, shows the code in action.

Autodesk Inventor ilogic - delete constraints joints and ground - clintbrown

'start of ilogic code
'Some code here was borrowed from Curtis, see
'This version of the code was first published on

Dim oAssDoc As AssemblyDocument

oAssDoc = ThisApplication.ActiveDocument
Dim oConstraint As AssemblyConstraint
Dim oJoint As AssemblyJoint

CheckWithUser = MessageBox.Show("Are you sure you want to Delete All Constraints?","iLogic - ClintBrown3D",MessageBoxButtons.YesNo)

If CheckWithUser = vbNo Then
i = 0
For Each oConstraint In oAssDoc.ComponentDefinition.Constraints
i = i + 1

ii = 0
For Each oJoint In oAssDoc.ComponentDefinition.Joints
ii = ii + 1

End If
MessageBox.Show(" A total of " & i & " constraints " & ii & " joints were deleted.", "iLogic - @ClintBrown3D")

qGround = True

'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")

'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
End If
End If
'ground everything in the top level
oOccurrence.Grounded = qGround

MessageBox.Show(" All Parts have been Grounded", "iLogic - @ClintBrown3D")
' end of ilogic code

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.

Comments are closed.

Create a website or blog at

Up ↑

%d bloggers like this: