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!

ShowAll and Hide Selected Parts Macro

Status
Not open for further replies.

killswitch

Mechanical
Jul 28, 2003
39
Last year I found a couple of macros on the web. One was for showing all parts of an assembly and the second hid all the selected components in an assembly. I found them very useful when working with large assemblies (or any assembly for that matter). I've recently changed jobs and I'm having no luck locating these macros again. If anyone has any suggestions where I can find macros like this I'd appreciate it. Hiding selected components is relatively easy but being able to click an icon and have everything shown is really nice (especially if the hidden parts are in sub-assemblies).

Thanks,
Killswitch
 
Replies continue below

Recommended for you

I have one of those:
Code:
'----------------------------------------------------
' How to show all components in an assembly

Option Explicit

'  The visibility information possible for Components.
Public Enum swComponentVisibilityState_e
    swComponentHidden = 0
    swComponentVisible = 1
End Enum

Sub SetCompVisib _
( _
    swComp As SldWorks.Component2, _
    sPadStr As String _
)
    Dim vChildArray         As Variant
    Dim swChildComp         As SldWorks.Component2
    Dim i                   As Long
    
    ' root component has no name ie empty string
    Debug.Print sPadStr & swComp.Name2 & " [" & swComp.Visible & "] --> " & swComp.IGetChildrenCount
    
    swComp.Visible = swComponentVisible
    
    vChildArray = swComp.GetChildren
    For i = 0 To UBound(vChildArray)
        Set swChildComp = vChildArray(i)
        SetCompVisib swChildComp, sPadStr & "  "
    Next i
End Sub

Sub main()
    Dim swApp               As SldWorks.SldWorks
    Dim swModel             As SldWorks.ModelDoc2
    Dim swAssy              As SldWorks.AssemblyDoc
    Dim swConfig            As SldWorks.Configuration
    Dim swRootComp          As SldWorks.Component2
    
    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swAssy = swModel
    Set swConfig = swAssy.GetActiveConfiguration
    Set swRootComp = swConfig.GetRootComponent

    Debug.Print "File = " & swModel.GetPathName
    
    SetCompVisib swRootComp, "  "
End Sub
'----------------------------------------------------

 
killswitch,
Check this one out: thread559-37101
Look for KenBolen (Mechanical)


Bradley
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor