Message 1 of 8
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am trying to figure out how to search thru all occurrences for a part filename called "Glass" and have it go thru the whole tree. I was able to make it work before and i thought that the code was going thru all occurrences in the tree but it is not. I had to move things around in my assembly and it has pushed the "glass" part file lower in the tree and my script cannot find it now. I have attached 2 pictures with the code and the path of my assembly while it was working and i have attached another picture showing the updated path of the "Glass file location. Any help would be appreciated.
Thanks
oDoc = ThisDoc.Document Dim doc = ThisDoc.Document : If doc.DocumentType = kAssemblyDocumentObject Then 'Check we are in an IAM Else : Return :End If Dim oDef As AssemblyComponentDefinition = oDoc.ComponentDefinition Dim oCompOcc As Inventor.ComponentOccurrence OccCounter = 0 For Each oCompOcc In oDef.Occurrences GetOccName = oCompOcc.Name OccCounter = OccCounter + 1 SubOccCount = 0 Try 'Top Level Occurrences If GetOccName.Contains("GLASS") Then MsgBox(GetOccName) Else If GetOccName.Contains("Glass") Then MsgBox(GetOccName) End If 'Sub level Occurrences For Each oSubOcc As ComponentOccurrence In oCompOcc.SubOccurrences SubOccCount = SubOccCount + 1 If oSubOcc.Name.Contains("GLASS") Then If GL1 = "" Then GL1 = oSubOcc.Name
Solved! Go to Solution.