Modify Plane by Editing Its Definition Example (VBA)
This example shows how to modify a plane by editing its definition.
'----------------------------------------------
'
' Preconditions:
' (1)
Model document is open.
' (2)
An offset plane named Plane1 exists.
'
' Postconditions: The offset distance for Plane1 is now
100mm.
'
'-----------------------------------------------
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swPart As SldWorks.PartDoc
Dim swModelDocExt As SldWorks.ModelDocExtension
Dim swSelMgr As SldWorks.SelectionMgr
Dim swRefPlane As SldWorks.RefPlaneFeatureData
Dim Feature As SldWorks.Feature
Dim boolstatus As Boolean
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swPart = swModel
Set swSelMgr = swModel.SelectionManager
Set swModelDocExt = swModel.Extension
boolstatus = swModelDocExt.SelectByID2("Plane1",
"PLANE", 0, 0, 0, False, 0, Nothing, swSelectOptionDefault)
Set Feature = swSelMgr.GetSelectedObject5(1)
Set swRefPlane = Feature.GetDefinition
swRefPlane.AccessSelections
swPart, Nothing
swRefPlane.distance
= 0.1
Feature.ModifyDefinition
swRefPlane, swPart, Nothing
End Sub