Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
The scenario I have is within an assembly I need to go through a preselected object collection and find certain occurrences of content centre parts within and change the visibility of solid bodies within. My code works fine when looping through all leaf occurrences of assembly but when I loop through only the object collection it does not update the parts, despite finding them fine.
TIA.
Public Sub SB2()
Dim oDoc As AssemblyDocument
Dim oInsul As String
Dim oOccurrence As ComponentOccurrence
Dim oPartDef As PartComponentDefinition
Dim oPartDoc As PartDocument
Dim oRunQty As Integer
Dim oSelectedEnts As ObjectCollection
Dim oSrfBod As SurfaceBody
Dim oSrfBods As SurfaceBodies
Dim oSrfBodProxy As SurfaceBodyProxy
Dim oVis As String
oDoc = g_inventorApplication.ActiveDocument
oVis = "FULL"
oInsul = "025"
oRunQty = 2
If oSelectedEnts Is Nothing Then
oSelectedEnts = g_inventorApplication.TransientObjects.CreateObjectCollection()
End If
For Each oItem In g_inventorApplication.ActiveDocument.SelectSet
oSelectedEnts.Add(oItem)
Next
For i = 1 To oRunQty
oOccurrence = oSelectedEnts.Item(i)
'loop through the sub occurences within each occurence in the object collection
'oDoc = g_inventorApplication.ActiveDocument
' For Each occ As ComponentOccurrence In oDoc.ComponentDefinition.Occurrences.AllLeafOccurrences - works fine for this scenario
For Each occ In oOccurrence.Definition.Occurrences.AllLeafOccurrences
If occ.DefinitionDocumentType = DocumentTypeEnum.kPartDocumentObject Then
If occ.Definition.Iscontentmember Then
oPartDef = occ.Definition
oPartDoc = oPartDef.Document
oSrfBods = oPartDef.SurfaceBodies
'show/hide solid bodies in the content center part occurences
For Each oSrfBod In oSrfBods
If oSrfBod.Name.Contains("FIT") Then
Else
If oSrfBod.Name = "INS_" & oInsul Or oSrfBod.Name = "SHL_" & oInsul Then
Call occ.CreateGeometryProxy(oSrfBod, oSrfBodProxy)
oSrfBodProxy.Visible = True
End If
End If
Next
End If
End If
Next
Next
End Sub
T
Solved! Go to Solution.