Weld Bead suppress not working when called from command button Click

Weld Bead suppress not working when called from command button Click

Anonymous
Not applicable
526 Views
2 Replies
Message 1 of 3

Weld Bead suppress not working when called from command button Click

Anonymous
Not applicable

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

0 Likes
Accepted solutions (1)
527 Views
2 Replies
Replies (2)
Message 2 of 3

adam.nagy
Autodesk Support
Autodesk Support
Accepted solution

Hi,

 

If you show a modal dialog that blocks most of the UI functionality, and that's what probably prevents the command from succeeding.

 

You would either have to make the Form non-modal (modeless) - see picture - or hide it while executing the command.

 

ModelessForm.png

 

Cheers,



Adam Nagy
Autodesk Platform Services
0 Likes
Message 3 of 3

Anonymous
Not applicable

Hi Adam

 

Yes its working. Thanks for your support

 

Regards

M.L.Kuselan

0 Likes