Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have an easy one for you guys,
I need a way to tell if a component occurence is a virtual component.
I'm using a For Each loop to cycle through all of the components in an assembly, and if the component is itself an assembly to set the LOD to "Custom". I'm using the definition document descriptor object for this. It all woks fine until the loop comes across a virtual component which doesn't have a definition document, so I need a way to check if the component is virtual and needs to be skipped.
Here's the code:
Option Explicit Imports Inventor.LevelOfDetailEnum Sub Main iLogicVb.UpdateWhenDone = True Dim doc As AssemblyDocument Dim oLOD As LevelOfDetailRepresentation Dim oAsmCompDef As ComponentDefinition Dim oComp As ComponentOccurrence Dim oComps As ComponentOccurrences doc = ThisDoc.Document If doc.ComponentDefinition.RepresentationsManager.ActiveLevelOfDetailRepresentation.LevelOfDetail <> kCustomLevelOfDetail Then oAsmCompDef = doc.ComponentDefinition oLOD = oAsmCompDef.RepresentationsManager.LevelOfDetailRepresentations.Item("Custom") oLOD.Activate(True) End If oComps = doc.ComponentDefinition.Occurrences On Error Goto handle For Each oComp In oComps If oComp.Suppressed = False Then If oComp.ReferencedDocumentDescriptor.ReferencedDocumentType = kAssemblyDocumentObject Then If oComp.ActiveLevelOfDetailRepresentation <> "Custom" Then oComp.SetLevelOfDetailRepresentation("Custom", True) End If 'MsgBox("Name: " & oComp.Name & " LOD: " & oComp.ActiveLevelOfDetailRepresentation) 'Else 'MsgBox("doc type: " & oComp.ReferencedDocumentDescriptor.ReferencedDocumentType) 'Exit For End If End If Next Exit Sub handle: MsgBox("LOD releated error in: " & oComp.Name, vbOKOnly, "LOD error") End Sub
Mike (not Matt) Rattray

Solved! Go to Solution.