Create and Name Planes Example (VBA)
This example shows how to create a series planes
that are offset from each other and change each of their names.
'---------------------------------------------
Public Sub CreateOffsetPlanes()
Dim swApp As
Object
Dim Part, Model
As Object
Dim planeName,
newPlaneName As String
Dim planeFeature
As Object
Dim i, planeCount
As Integer
Set swApp =
CreateObject("SldWorks.Application")
Set Model =
swApp.ActiveDoc
If Model Is
Nothing Then
Exit Sub
End If
newPlaneName
= "Plane1"
planeCount =
3
' Loop five times and create five planes
offset from each other
For i = 1 To
5
Model.ClearSelection
Model.SelectByID newPlaneName, "PLANE",
0, 0, 0
Model.CreatePlaneAtOffset 0.1, 0
planeCount =
planeCount + 1
planeName =
"Plane" & planeCount
newPlaneName
= "MyPlane" & i
Set planeFeature
= Model.FeatureByName(planeName)
planeFeature.Name = (newPlaneName)
Model.EditRebuild
Next
End Sub