Message 1 of 1
All Components Enabled in an Assembly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have a button that makes all components 'Enabled' in an assembly.
When I then apply a constraint and click OK, the constraint has not been created and the components that were previously Not Enabled are again set to Not Enabled, see video.
It seems that 'Enabled = True' is not doing its job?
Does it have to be different? See code.
Sub Main
Try
' Get the active assembly.
Dim oAssyDoc As AssemblyDocument
oAssyDoc = ThisApplication.ActiveDocument
'----------------------------------------------------------------------------------------------------
' Undo Wrapper
Dim trans As Transaction = ThisApplication.TransactionManager.StartTransaction(oAssyDoc, "Do your thing")
'----------------------------------------------------------------------------------------------------
TraverseAssembly(oAssyDoc.ComponentDefinition.Occurrences)
iLogicVb.UpdateWhenDone = True
'----------------------------------------------------------------------------------------------------
' Undo Wrapper
trans.End()
'----------------------------------------------------------------------------------------------------
Catch
' No Assembly?
End Try
End Sub
Sub TraverseAssembly(oOccs As ComponentOccurrences, Optional entityName As String = "")
' Iterate through all of the occurrence in this collection
Dim oOcc As ComponentOccurrence
For Each oOcc In oOccs
'If oOcc.Visible = True Then
'If oOcc.Enabled = False Then oOcc.Enabled = True
'End If
oPart = Component.InventorComponent(oOcc.Name)
oPart.Enabled = True
' Use DoEvents to force Inventor to wait till the code is finished...
Call ThisApplication.UserInterfaceManager.DoEvents
' Recursively call sub if needed
If oOcc.DefinitionDocumentType = kAssemblyDocumentObject Then
Call TraverseAssembly(oOcc.SubOccurrences)
End If
Next
End Sub