Get Plane on which Sketch Created Example (VBA)
This example shows how to get the plane on which the sketch used for
the feature was created.
'---------------------------------------------
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swSelMgr As SldWorks.SelectionMgr
Dim swFeat As SldWorks.feature
Dim boolstatus As Boolean
Dim longstatus As Long
Dim parents As Variant
Dim swParentFeat As SldWorks.feature
Dim swSketch As SldWorks.sketch
Dim swSketchPlane As Object
Dim i As Long
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swSelMgr = swModel.SelectionManager
boolstatus = swModel.Extension.SelectByID2("Revolve1",
"BODYFEATURE", 0, 0, 0, False, 0, Nothing, swSelectOptionDefault)
Set swFeat = swSelMgr.GetSelectedObject5(1)
parents = swFeat.GetParents
For i = 0 To UBound(parents)
Set
swParentFeat = parents(i)
If
swParentFeat.GetTypeName = "ProfileFeature"
Then
Set
swSketch = swParentFeat.GetSpecificFeature2
Set
swSketchPlane = swSketch.GetReferenceEntity(longstatus)
'The
plane can be either a face or a Feature object
End
If
Next i
End Sub