iLogic To Find Grounded and Unresolved Components

iLogic To Find Grounded and Unresolved Components

Anonymous
Not applicable
959 Views
1 Reply
Message 1 of 2

iLogic To Find Grounded and Unresolved Components

Anonymous
Not applicable

Does anyone have a good iLogic script for finding and highlighting unresolved components in an assembly? Would be nice to have a script for finding these components rather than digging through multiple levels of an assembly looking for a "?".

 

Additionally does anyone have anything for identifying grounded components within an assembly?

0 Likes
Accepted solutions (1)
960 Views
1 Reply
Reply (1)
Message 2 of 2

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi @Anonymous 

 

Here are a couple of examples.

 

Note that you can search and ask programming questions of this type on the Inventor Customization forum:
http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/bd-p/120

 

Find Unresolved components

Sub main
    Dim oFile As Inventor.File
    oFile = ThisApplication.ActiveDocument.File
    
    Dim oDoc As AssemblyDocument
    oDoc = ThisApplication.ActiveDocument

    Dim oDocDef As AssemblyComponentDefinition
    oDocDef = oDoc.ComponentDefinition
    
    Call FindUnresolved(oFile, oDoc, oDocDef)

End Sub
Sub FindUnresolved(ByVal oFile As Inventor.File, oDoc As AssemblyDocument, oDocDef As ComponentDefinition)

Dim oSelection As SelectSet
oSelection = oDoc.SelectSet
oSelection.Clear

Dim oCollection As ObjectCollection
oCollection = ThisApplication.TransientObjects.CreateObjectCollection

    Dim oFileDescriptor As FileDescriptor
    For Each oFileDescriptor In oFile.ReferencedFileDescriptors
        If Not oFileDescriptor.ReferenceMissing Then
            If Not oFileDescriptor.ReferencedFileType = FileTypeEnum.kForeignFileType Then
                Call FindUnresolved(oFileDescriptor.ReferencedFile, oDoc, oDocDef)
            End If
        Else
	        Dim oOccurrence As ComponentOccurrence
	        For Each oOccurrence In oDocDef.Occurrences.AllLeafOccurrences
	        If oOccurrence.ReferencedDocumentDescriptor.ReferencedFileDescriptor.FullFileName _
				 = oFileDescriptor.FullFileName Then
	       		oCollection.Add(oOccurrence)
	        End If
	        Next oOccurrence
        End If                   
    Next
	
	oSelection.SelectMultiple(oCollection)
	
End Sub

 

Select grounded components

Dim oDoc As AssemblyDocument 
oDoc = ThisApplication.ActiveDocument

Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = oDoc.ComponentDefinition

Dim oSelection As SelectSet
oSelection = oDoc.SelectSet
oSelection.Clear

Dim oCollection As ObjectCollection
oCollection = ThisApplication.TransientObjects.CreateObjectCollection

Dim oOccurrence As ComponentOccurrence
For Each oOccurrence In oAsmCompDef.Occurrences
                         
   If oOccurrence.Grounded = True Then
	   oCollection.Add(oOccurrence)
   End If 
Next  

oSelection.SelectMultiple(oCollection)

EESignature