'This iLogic code originally appeared on Cadline Community 'https://www.cadlinecommunity.co.uk/hc/en-us/articles/214079065 Dim oDoc As AssemblyDocument = ThisDoc.Document Dim oAsmDef As AssemblyComponentDefinition = oDoc.ComponentDefinition Dim oLoD As LevelofDetailRepresentation = oAsmDef.RepresentationsManager.ActiveLevelofDetailRepresentation Dim newLod As LevelofDetailRepresentations = oAsmDef.RepresentationsManager.LevelofDetailRepresentations Dim oConstrs As AssemblyConstraints = oAsmDef.Constraints 'Check if this is an assembly If oDoc.DocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then MessageBox.Show("This rule is only for assemblies.") End If 'Check that we have selected something If oDoc.SelectSet.Count = 0 Then MessageBox.Show("Nothing selected") Exit Sub End If 'Create a flag to check against later in case no valid selections were made ValidSelection = False 'Cycle through each selected component For Each oOcc In oDoc.SelectSet 'The try will catch anything that is not a component or constraint Try If oOcc.DefinitionDocumentType = kAssemblyDocumentObject Or oOcc.DefinitionDocumentType = kPartDocumentObject Then ValidSelection = True 'Cycle through each constraint in the assembly For Each oConstr As AssemblyConstraint In oConstrs 'Compare the component suppression state with the constraint and act If oConstr.Suppressed = oOcc.Suppressed Then 'Suppress the constraint if the first half is used by the component Try If oConstr.OccurrenceOne.Name = oOcc.Name Then Constraint.IsActive(oConstr.Name) = Not Constraint.IsActive(oConstr.Name) End If Catch End Try 'Suppress the constraint if the second half is used by the component Try If oConstr.OccurrenceTwo.Name = oOcc.Name Then Constraint.IsActive(oConstr.Name) = Not Constraint.IsActive(oConstr.Name) End If Catch End Try End If Next End If 'Finally suppress the component Try Component.IsActive(oOcc.Name) = Not Component.IsActive(oOcc.Name) Catch 'Need to add an editable LoD if currently using the defaults newLod.Add("NewLod") Component.IsActive(oOcc.Name) = Not Component.IsActive(oOcc.Name) End Try Catch End Try Next 'Notify the user that no valid selection was made If ValidSelection = False Then MessageBox.Show("No components selected") End If