
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
The following code works and suppress the weldbead when it is placed in module and run from module
BUT WHEN THE SAME CODE CALLED FROM COMMAND BUTTON CLICK IN USERFORM ITS NOTWORKING.
THE WELDBEAD GETS SELECTED BUT IT IS NOT GETTING SUPPRESSED I DON'T KNOW WHY.
please someone help in this work.
Enum SuppressOption
kSuppress
kUnsuppress
kToggle
End Enum
Private Sub SuppressWeldBeads_Click()
Call SuppressWeldBead("Fillet Weld 1")
End Sub
Sub SuppressBead(wcd As WeldmentComponentDefinition, wbn As BrowserNode, _
so As SuppressOption)
Dim name As String
name = wbn.BrowserNodeDefinition.Label
'We only need to check the current state of the bead if
'We are not just toggling its state but want a specific one
If so <> kToggle Then
'If the bead is already suppressed then its
'BeadFaces.Count will be 0
Dim bfs As Faces
Set bfs = wcd.Welds.WeldBeads(name).BeadFaces
If bfs.Count = 0 Xor so = kUnsuppress Then Exit Sub
End If
'Get the commandManager object
Dim cm As CommandManager
Set cm = ThisApplication.CommandManager
'Get the collection of control definitions
Dim cds As ControlDefinitions
Set cds = cm.ControlDefinitions
'Run the "Suppress" command
ThisApplication.SilentOperation = True
Call wbn.DoSelect
Dim oSuppControlDef As ControlDefinition
Set oSuppControlDef = ThisApplication.CommandManager.ControlDefinitions.Item("AssemblySuppressFeatureCtxCmd")
oSuppControlDef.Execute2 (True)
'Call cds("AssemblySuppressFeatureCtxCmd").Execute
ThisApplication.SilentOperation = False
End Sub
Sub SuppressWeldBead(WeldName As String)
'MsgBox (WeldName)
'Dim WeldName As String
'WeldName = "Fillet Weld 1"
'Get Document
Dim doc As AssemblyDocument
Set doc = ThisApplication.ActiveDocument
Dim wcd As WeldmentComponentDefinition
Set wcd = doc.ComponentDefinition
'Get "Model" browser
Dim bp As BrowserPane
Set bp = doc.BrowserPanes("AmBrowserArrangement")
'Get "Welds" node
Dim wbn As BrowserNode
For Each wbn In bp.TopNode.BrowserNodes
If wbn.BrowserNodeDefinition.Label = "Welds" Then
Exit For
End If
Next
'Get "Beads" node
Dim bbn As BrowserNode
For Each bbn In wbn.BrowserNodes
If bbn.BrowserNodeDefinition.Label = "Beads" Then
Exit For
End If
Next
'Get the Beads we want to suppress
For Each wbn In bbn.BrowserNodes
If wbn.BrowserNodeDefinition.Label = WeldName Then
Call SuppressBead(wcd, wbn, kSuppress)
End If
Next
End Sub
Solved! Go to Solution.