Create Variable-Radius with Control Points Fillet Example (VBA)
This example shows how to create a variable-radius fillet using control
points.
'------------------------------------------------------------
'
' Preconditions: Part document is open and an edge on
the part is selected.
'
' Postconditions: Variable radius fillet is created along
the selected edge.
'
' NOTE: You must calculate the control points on the selected
edge. The
' code
shown here will most likely not work for your part.
'
'------------------------------------------------------------
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swModelDocExt As SldWorks.ModelDocExtension
Dim swFeatMgr As SldWorks.FeatureManager
Dim VarRadArray3 As Variant
Dim radArray3(1) As Double
Dim VarPointRadArray3 As Variant
Dim pointRadArray3(2) As Double
Dim boolstatus As Boolean
Dim FilletOptions As Long
Sub main()
Set
swApp = Application.SldWorks
Set
swModel = swApp.ActiveDoc
Set
swModelDocExt = swModel.Extension
Set
swFeatMgr = swModel.FeatureManager
swModel.ClearSelection2 True
'Select
the edge
boolstatus
= swModelDocExt.SelectByID2("",
"EDGE", -0.01721376786878, 0.05215099349829, 0.08927826759844,
False, 1, Nothing, 0)
'Select
the control points
boolstatus
= swModelDocExt.SelectByID2("Unknown",
"POINTREF", -0.0349919889052, 0.05256058084516, 0.089, True,
256, Nothing, 0)
boolstatus
= swModelDocExt.SelectByID2("Unknown",
"POINTREF", -0.001887534671235, 0.05256058084516, 0.089, True,
256, Nothing, 0)
boolstatus
= swModelDocExt.SelectByID2("Unknown",
"POINTREF", 0.03121691956273, 0.05256058084516, 0.089, True,
256, Nothing, 0)
'Fillet
radii
radArray3(0)
= 0.01
radArray3(1)
= 0.01
VarRadArray3
= radArray3
'Control
points radii
pointRadArray3(0)
= 0.002
pointRadArray3(1)
= 0.005
pointRadArray3(2)
= 0.002
VarPointRadArray3
= pointRadArray3
'Fillet
options
FilletOptions
= swFeatureFilletPropagate + swFeatureFilletUniformRadius + swFeatureFilletVarRadiusType
'Create
variable radius fillet
swFeatMgr.FeatureFillet FilletOptions, 0.01, swFeatureFilletType_VariableRadius,
swFilletOverFlowType_Default, (VarRadArray3), 0, (VarPointRadArray3)
End Sub