Assemblies "Show All Parts", is there any such function
Assemblies "Show All Parts", is there any such function
(OP)
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.






RE: Assemblies "Show All Parts", is there any such function
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
RE: Assemblies "Show All Parts", is there any such function
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
RE: Assemblies "Show All Parts", is there any such function
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

credence69@REMOVEhotmail.com
http://www.3dmca.com
http://home.insightbb.com/~scott.baugh/
*When in doubt always check the help*
RE: Assemblies "Show All Parts", is there any such function
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: www.KentContract.com
' 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 ("Active document is not an assembly!")
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 = "Macro cancelled..."
swApp.SendMsgToUser2 Message, swMbInformation, swMbOk
Done:
End Sub
RE: Assemblies "Show All Parts", is there any such function
I'd like to recommend the following to everyone:
- - -DennisD
RE: Assemblies "Show All Parts", is there any such function
Does your "ShowOnly.swp" work for assemblies with sub-assemblies? If it does, could you share it with other members?
Thanks,
Alex
RE: Assemblies "Show All Parts", is there any such function
Its does almost everything you want,
RE: Assemblies "Show All Parts", is there any such function
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