Message 1 of 34
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Does anyone out there know of a faster (more efficient) way to suppress welds (single or multiple) then my example.
Sub Main ' Get the active assembly. Dim doc As AssemblyDocument oAsmDoc = ThisApplication.ActiveDocument 'REPLACE ITEM SuppressWeldBead() InventorVb.DocumentUpdate() iLogicVb.UpdateWhenDone = True End Sub Enum SuppressOption kSuppress kUnsuppress kToggle End Enum 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 1 Dim bfs As Faces bfs = wcd.Welds.WeldBeads(name).BeadFaces If bfs.Count = 1 Xor so = kUnsuppress Then Exit Sub End If ' Get the CommandManager object Dim cm As CommandManager cm = ThisApplication.CommandManager ' Get the collection of control definitions Dim cds As ControlDefinitions cds = cm.ControlDefinitions ' Run the "Suppress" command ThisApplication.SilentOperation = True Call wbn.DoSelect Call cds("AssemblySuppressFeatureCtxCmd").Execute2(True) ThisApplication.SilentOperation = False End Sub Sub SuppressWeldBead() Dim weldName As String weldName = "Fillet Weld 78" ' Get document Dim doc As AssemblyDocument doc = ThisApplication.ActiveDocument Dim wcd As WeldmentComponentDefinition wcd = doc.ComponentDefinition ' Get "Model" browser Dim bp As BrowserPane 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 Dim timeout = 3 ' secs TimeSpan.FromSeconds(timeout) ' 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.