Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations MintJulep on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Assemblies "Show All Parts", is there any such function 2

Status
Not open for further replies.

borsht

Mechanical
Oct 9, 2002
262
I want to be able to show, or Unsuppress all parts in all of the subassemblies in my assembly. This question comes from my background in awetodesk MDT, where you could: hide all, unhide all, hide all except, unhide all except, and so on.


 
Replies continue below

Recommended for you

Hello,

Unfortunately there is no select all command per se.

However, you can select all the components using a window select (click hold drag) in the graphics window. Or shift select in the feature manager.

You can then hold CTRL key and deselect individual components.

cheers,

Joseph
 
BOBORUSH,
A very un-clean approach can be done. I do not like it nor do I use this approach. You can have all the plus signs for all assemblies in the tree set to minus. Now right mouse click (RMC) on the first component in the tree. Hold the shift key down and (RMC) on a component as far down the tree as you wish. You will have several components highlighted. Now (RMC) in the tree, a dialog box comes up and you pick Hide components. Now reselect the components again. Now (RMC) in the tree again, a dialog box comes up and you pick Show components. Your components are now showing. If you have a plus sign at one of the assemblies, any hidden components in that assembly will not become shown. Bradley
 
In the feature toolbar there are 2 icons that don't come in the toolbar by default, you have to add them yourself. They are Unsuppress and Suppress icons. Get those icons out and on to your toolbar, and like it is specified above highlight the components or all the components. Instead of RMB the FM, just click the icon to suppress or unsuppress the items in the FM.

This takes out a lot of steps and is so much easier in my opinion. I have been using these icons for many years now so once you get used to using them you wonder why did it the other way. Scott Baugh, CSWP [spin] [americanflag]
credence69@REMOVEhotmail.com

*When in doubt always check the help*
 
If you can deal with it being a Macro, I pasted one at the end of this post. I went to the author's website but didn't see this one there, so had to get it off of my computer.

There is a HideShow.swp and a ShowOnly.swp macro at his site, but if I remember correctly ShowOnly didn't work completely correct for subassemblies (can't remember for sure). Not sure if HideShow had the same problem or not? I do have a macro for ShowOnly, that I think I got off of the SW forum at Google that works pretty good, and I'll put it in a new thread if anyone is interested.



' ******************************************************************************
' ShowAll.swb (Rev 2) - macro recorded on 07/19/02 by Kent
' Shows all components in an assembly
' ******************************************************************************
'
' Kent Contract Services
' on the web: ' e-mail: info@KentContract.com
' This macro is provided as-is with no warranty or liability
' Kent Contract Services shall not be liable for any damages of any kind
' incurred through use or mis-use of this macro
'
' Lines (2) marked with ** Show ** are for showing components
' Lines (1) marked with ** Resolve ** are for resolving components
' Comment these lines out according to your needs
'
' *******************************************************************************
Dim swApp, AssemblyDoc As Object

' Routine to traverse all the children of the root component
Private Function TraverseComponent(Level As Integer, Component As Object)
Dim i As Integer
Dim Children As Variant
Dim Child As Object
Dim ChildCount As Integer

' Perform component specific operations...

Children = Component.GetChildren ' Get the list of children

' Get the # of elements in the variant safearray. UBound returns the
' upper element number. Since the array begins at zero, we must add 1
' to get the actual number of array elements. If no elements are
' in the array, then UBound returns -1.

ChildCount = UBound(Children) + 1

' Add each Child in this Assembly to the selection set
For i = 0 To (ChildCount - 1)
Set Child = Children(i) ' Get Child component object
Children(i).Select True ' ** Show **
TraverseComponent Level + 1, Child ' Traverse the child's components
' Options for below are swComponentFullyResolved & swComponentSuppressed
'Child.SetSuppression (swComponentFullyResolved) ' ** Resolve **

Next i

End Function

Sub main()

Dim Configuration As Object
Dim RootComponent As Object

Set swApp = CreateObject("SldWorks.Application")
Set AssemblyDoc = swApp.ActiveDoc

If AssemblyDoc Is Nothing Then ' Check to see if a document is loaded.
swApp.SendMsgToUser ("Nothing is loaded!")
GoTo CancelMacro ' If no model currently loaded, then exit
End If

' Determine the document type. If the document not an assembly then send a message to the user.
If (AssemblyDoc.GetType <> swDocASSEMBLY) Then
swApp.SendMsgToUser (&quot;Active document is not an assembly!&quot;)
GoTo CancelMacro ' Current model not an assembly
End If

AssemblyDoc.ClearSelection

' Find the Root Component
Set Configuration = AssemblyDoc.GetActiveConfiguration()
Set RootComponent = Configuration.GetRootComponent()

' Traverse the root component and select everything
If Not RootComponent Is Nothing Then
TraverseComponent 1, RootComponent
End If

AssemblyDoc.ShowComponent2 ' ** Show **
AssemblyDoc.ClearSelection

GoTo Done

CancelMacro:
Message = &quot;Macro cancelled...&quot;
swApp.SendMsgToUser2 Message, swMbInformation, swMbOk

Done:

End Sub
 
Scott Baugh brings up a good point. I, too have been using the Suppress, Unsupress and Unsupress with Dependents buttons on my Features toolbar.

I'd like to recommend the following to everyone:
[thumbsup2] DO customize your toolbars. Take off the things you don't need and add the things you probably will use. I even add the things I do infrequently, such as the parabola in the sketch tools. I find that &quot;out of sight = out of mind&quot; is very true. So if it is not on a toolbar I might forget that that ability is there. And since there are multiple ways to solve any problem I might end up using a kludge (of various degrees) depending on the abilities I am most familiar with.

- - -DennisD
 
Hi, KenBolen:

Does your "ShowOnly.swp" work for assemblies with sub-assemblies? If it does, could you share it with other members?

Thanks,

Alex
 
rgrayclamps,

I second joshposh's recommendation. You'll find the Visibility Toggling program will do just what you're looking for.

As far as the ShowOnly Macro...yes it hides everything except the selected components no matter which subassembly they are a component of. I'll paste it in below. Again, I am not the original author and use at your own risk.

Ken

Code:
' ******************************************************************************
' c:\temp\swx1836\Macro1.swb - macro recorded on 07/04/02 by chen
' ******************************************************************************
Dim swApp As Object
Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long
Dim Annotation As Object
Dim Gtol As Object
Dim DatumTag As Object
Dim FeatureData As Object
Dim Feature As Object
Dim Component As Object
Global selected(1000) As Variant

Sub TraverseAssyArray(ByVal ComponentIn As Object)

Dim Component, modelDoc As Object
Dim componentName As String
Dim Children As Variant
Dim Child As Object
Dim ChildCount As Integer
Dim isRootComponent As Boolean
Dim visible As Long
Dim doc As Object

Set swApp = CreateObject("SldWorks.Application")
Set model = swApp.ActiveDoc ' Current document
Set Component = ComponentIn         ' Accept the component passed in
Set SelMgr = model.SelectionManager

    If Component Is Nothing Then        ' If no component, then exit
        Exit Sub
    End If
        
    componentName = Component.Name      ' Get the component name
    Children = Component.GetChildren    ' Get the list of children (if any)
    
    If (IsEmpty(Children)) Then         ' If array contains no children, then recurse out
        Exit Sub
    End If
    
    ChildCount = UBound(Children) + 1
    If (ChildCount > 0) Then
            
    
        j = 0
        For i = 0 To (ChildCount - 1)       ' For each Child in this subassembly, get its children
            Set Child = Children(i)             ' Get component from array of children
            If Not (Child.IsSuppressed) Then
                If Child.GetModelDoc.gettype = 1 Then
                    partselected = False
                    For q = 1 To 1000
                        If Child.Name = selected(q) Then
                            partselected = True
                        End If
                    Next
                    If partselected Then
                        retval = Child.deSelect()
                    Else
                        retval = Child.select(True)
                    End If
                    p = p + 1
                Else
                    TraverseAssyArray Child                  ' Recurse In and traverse this child component
                End If
            End If
        Next i
            
        Level = Level - 1                   ' Adjust level as we come out of recursion
            
    End If
End Sub
Sub main()

Dim swApp As Object
Dim doc As Object
Dim RootComponent, Configuration As Object
Dim SelMgr As Object

Set swApp = CreateObject("SldWorks.Application")
Set doc = swApp.ActiveDoc ' Current document

For i = 1 To 1000
    selected(i) = ""
Next

   If doc Is Nothing Then
     MsgBox "No document was opened"
     Exit Sub
   ElseIf doc.gettype = 1 Or doc.gettype = 3 Then
     MsgBox "Toggle Selection applies only to assemblies"
     Exit Sub
   End If
   
 Set SelMgr = doc.SelectionManager
 For i = 1 To 1000
    Set curcomp = SelMgr.GetSelectedObject3(i)
    selType = SelMgr.GetSelectedObjectType2(i)   ' Check the selected object type
    If selType = 2 Or selType = 1 Or selType = 3 Then
        Set curcomp = curcomp.GetComponent
        curcomp.select (True)
        selected(i) = curcomp.Name
    End If
 Next
  For i = 1 To 1000
    Set curcomp = SelMgr.GetSelectedObject3(i)
    selType = SelMgr.GetSelectedObjectType2(i)   ' Check the selected object type
    If selType = 20 Then    ' If item is face, edge or vertex
       selected(i) = curcomp.Name ' Get the owning Component object
    End If
Next
 Set Configuration = doc.GetActiveConfiguration()
 Set RootComponent = Configuration.GetRootComponent()

 doc.ResolveAllLightWeightComponents True
 
 If Not RootComponent Is Nothing Then
    doc.clearselection
    TraverseAssyfaces RootComponent
 End If
For i = 1 To 1000
    selected(i) = ""
Next

 For j = 1 To 1000
    Set curcomp = SelMgr.GetSelectedObject3(j)
    selType = SelMgr.GetSelectedObjectType2(j)   ' Check the selected object type
    If selType = 20 Then    ' If item is face, edge or vertex
       selected(j) = curcomp.Name ' Get the owning Component object
    ElseIf selType = 2 Then  'Or selType = 1 Or selType = 3
        Set curcomp = curcomp.GetComponent
        selected(j) = curcomp.Name
    End If
 Next j
 
 Set Configuration = doc.GetActiveConfiguration()
 Set RootComponent = Configuration.GetRootComponent()

 doc.ResolveAllLightWeightComponents True
 
 If Not RootComponent Is Nothing Then
    TraverseAssyArray RootComponent
 End If
 doc.HideComponent2

End Sub
Sub TraverseAssyfaces(ByVal ComponentIn As Object)

Dim Component, modelDoc As Object
Dim componentName As String
Dim Children As Variant
Dim Child As Object
Dim ChildCount As Integer
Dim isRootComponent As Boolean
Dim visible As Long
Dim doc As Object

Set swApp = CreateObject("SldWorks.Application")
Set model = swApp.ActiveDoc ' Current document
Set Component = ComponentIn         ' Accept the component passed in
Set SelMgr = model.SelectionManager
'model.clearselection

    If Component Is Nothing Then        ' If no component, then exit
        Exit Sub
    End If
        
    componentName = Component.Name      ' Get the component name
    Children = Component.GetChildren    ' Get the list of children (if any)
    
    If (IsEmpty(Children)) Then         ' If array contains no children, then recurse out
        Exit Sub
    End If
    
    ChildCount = UBound(Children) + 1
    If (ChildCount > 0) Then
            
    
        j = 0
        For i = 0 To (ChildCount - 1)       ' For each Child in this subassembly, get its children
            Set Child = Children(i)             ' Get component from array of children
            If Not (Child.IsSuppressed) Then
                If Child.GetModelDoc.gettype = 1 Then
                    partselected = False
                    For q = 1 To 1000
                        If Child.Name = selected(q) Then
                            partselected = True
                        End If
                    Next
                    If partselected Then
                        retval = Child.select(True)
                    End If
                Else
                    TraverseAssyfaces Child                  ' Recurse In and traverse this child component
                End If
            End If
        Next i
            
        Level = Level - 1                   ' Adjust level as we come out of recursion
            
    End If
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor