Determine if Sketch is Shared Example (VBA)
This example shows how to determine whether or not a sketch is shared
with multiple features.
'-----------------------------------------------
'
' Preconditions:
' (1)
Part, assembly, or drawing document is open.
' (2)
Sketch is selected.
'
' Postconditions: None
'
'-----------------------------------------------
Option Explicit
Sub main()
Dim
swApp As
SldWorks.SldWorks
Dim
swModel As
SldWorks.ModelDoc2
Dim
swSelMgr As
SldWorks.SelectionMgr
Dim
swFeat As
SldWorks.feature
Dim
swSketch As
SldWorks.sketch
Dim
i As
Long
Dim
bRet As
Boolean
Dim
vChildArr As
Variant
Dim
vChild As
Variant
Dim
swChildFeat As
SldWorks.feature
Set
swApp = Application.SldWorks
Set
swModel = swApp.ActiveDoc
Set
swSelMgr = swModel.SelectionManager
Set
swFeat = swSelMgr.GetSelectedObject5(1)
Set
swSketch = swFeat.GetSpecificFeature2
Debug.Print
"File = " & swModel.GetPathName
Debug.Print
" Sketch
= " & swFeat.Name
Debug.Print
" IsShared
= " & swSketch.IsShared
vChildArr
= swFeat.GetChildren: If IsEmpty(vChildArr)
Then Exit Sub
For
Each vChild In vChildArr
Set
swChildFeat = vChild
Debug.Print
" "
& swChildFeat.Name & "
[" & swChildFeat.GetTypeName
& "]"
Next
vChild
End Sub
'-----------------------------------------------