Get Data for Surface-flatten Feature Example (VBA)
This example shows how to create a surface-flatten feature and get its data.
'----------------------------------------------------------------------------
' Preconditions:
' 1. Open install_dir\samples\tutorial\api\toaster.sldprt.
' 2. Open an Immediate window.
'
' Postconditions:
' 1. Creates Surface-Flatten1 in the FeatureManager design tree.
' 2. Inspect the Immediate window.
'
' NOTE: Because this part document is used elsewhere, do not save changes
' when closing it.
'---------------------------------------------------------------------------
Option Explicit
Sub main()
Dim swApp
As SldWorks.SldWorks
Dim Part
As SldWorks.ModelDoc2
Dim swFeat
As SldWorks.Feature
Dim swSurfFlatten
As SldWorks.SurfaceFlattenFeatureData
Dim boolstatus
As Boolean
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
boolstatus = Part.Extension.SelectByID2("",
"FACE", 3.43791439121333E-02, 0.113529021755539, 9.78513589013232E-02, True, 1,
Nothing, 0)
boolstatus = Part.Extension.SelectByID2("",
"VERTEX", 6.65960136495036E-02, 0.141573958827054, 0.1016, True, 16, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("",
"EDGE", 0.054235249930457, 0.105966292673031, 0.102108078588174, True, 2,
Nothing, 0)
boolstatus = Part.Extension.SelectByID2("",
"EDGE", 2.22348071149554E-02, 6.20036139007993E-02, 9.63411782521462E-02, True,
2, Nothing, 0)
Set swFeat = Part.FeatureManager.InsertFlattenSurface(5)
'boolstatus = Part.Extension.SelectByID2("Surface-Flatten1",
"REFSURFACE", 0, 0, 0, False, 0, Nothing, 0)
'Set swFeat = Part.SelectionManager.GetSelectedObject6(1,
-1)
Set swSurfFlatten = swFeat.GetDefinition
swSurfFlatten.AccessSelections Part, Nothing
Debug.Print "File = " & Part.GetPathName
Debug.Print "Feature = " & swFeat.Name
Debug.Print " Accuracy of flattened triangle mesh
= " & swSurfFlatten.AccuracyFactor
Debug.Print " Keep internal control curves =
" & swSurfFlatten.KeepInternalControlCurves
swSurfFlatten.ReleaseSelectionAccess
End Sub