I've been working on code to show all envelopes for selected sub-assemblies. This code gets the sub-components that are envelopes, but the line to make them visible doesn't work. Anyone have an idea why?
Dim swApp As SldWorks.SldWorks
Dim swPart As SldWorks.ModelDoc2
Dim swSelMgr As SelectionMgr
Dim myComp As Object
Dim mySubPart As Object
Dim boolstatus As Boolean
Dim c As Integer
Dim i As Integer
Sub main()
Set swApp = Application.SldWorks
Set swPart = swApp.ActiveDoc
Set swSelMgr = swPart.SelectionManager
c = swSelMgr.GetSelectedObjectCount
For i = 1 To c
Set myComp = swSelMgr.GetSelectedObject6(i, -1)
Set mySubPart = myComp.GetModelDoc2
If mySubPart.GetType = 2 Then
Dim swSubAssy As SldWorks.AssemblyDoc
Dim vComps As Variant
Dim swComp As SldWorks.Component2
Dim j As Integer
Set swSubAssy = mySubPart
vComps = swSubAssy.GetComponents(False)
For j = 0 To UBound(vComps)
Set swComp = vComps(j)
Debug.Print swComp.Visible
Debug.Print swComp.IsEnvelope
If swComp.IsEnvelope Then swComp.Visible = True
Next
End If
Next
End Sub
Thanks,
Mark
SolidworksApi macros