Message 1 of 2
Update a Simplify Substitute
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I would creat a code to update a simplify Substitute as here (chapter "To Edit a Simplify Substitute")
but I can't code the action "Edit Simplified Assembly":
Sub ActualiseSubstitute()
' Set a reference to the active assembly document
Dim oDoc As AssemblyDocument
Dim oDef As AssemblyComponentDefinition
Dim oModelStates As ModelStates
Dim oModelState As ModelState
Dim oSubstitute() As String
Dim i As Long
Dim MyModelState As ModelState
Dim AssName As String
Set oDoc = ThisApplication.ActiveDocument
Set oDef = oDoc.ComponentDefinition
Set oModelStates = oDef.ModelStates
'Active Master state
If oModelStates.ActiveModelState.Name <> oModelStates.Item(1).Name Then
Set MyModelState = oModelStates.Item(1)
MyModelState.Activate
End If
AssName = oDoc.DisplayName
'for future if i want have the choice
i = 1
For Each oModelState In oModelStates
If oModelState.ModelStateType = kSubstituteModelStateType Then
ReDim Preserve oSubstitute(1 To i)
oSubstitute(i) = oModelState.Name
i = i + 1
End If
Next
Dim MyOccName As String
Dim oCompOccSympl As ComponentOccurrence
Dim oCompOccAssSympl As ComponentOccurrence
Set oDoc = ThisApplication.ActiveDocument
Set oDef = oDoc.ComponentDefinition
Set oModelStates = oDef.ModelStates
'Active the first Substitute
If oModelStates.ActiveModelState.Name <> oModelStates.Item(oSubstitute(1)).Name Then
Set MyModelState = oModelStates.Item(oSubstitute(1))
MyModelState.Activate
End If
MyOccName = MyModelState.Name
'Edit the first Substitute
Set oDoc = ThisApplication.ActiveDocument
Set oDef = oDoc.ComponentDefinition
Set oCompOccSympl = oDef.Occurrences.ItemByName(MyOccName & ":1")
oCompOccSympl.Edit
'Edit Simplified Assembly
Dim oSimplDoc As PartDocument
Dim oSimplDef As PartComponentDefinition
Dim oShrinkComp As ShrinkwrapComponent
Set oSimplDoc = ThisApplication.ActiveEditDocument
Set oSimplDef = oSimplDoc.ComponentDefinition
Set oShrinkComp = oSimplDef.ReferenceComponents.ShrinkwrapComponents.Item(1)
End Sub
Could you help me ?