Rename Active Sketch Example (VBA)
This example shows how to rename the active sketch.
'--------------------------------
'
' Preconditions: Sketch that you want to rename
' is
active (i.e., open).
'
' Postconditions: The name of the active sketch is
' changed
to CircleSketch.
'
'---------------------------------
Option Explicit
Sub main()
Dim
swApp As
SldWorks.SldWorks
Dim
swModel As
SldWorks.ModelDoc2
Dim
swSketch As
SldWorks.Sketch
Dim
swFeat As
SldWorks.Feature
Set
swApp = Application.SldWorks
Set
swModel = swApp.ActiveDoc
'
Get the open sketch
Set
swSketch = swModel.GetActiveSketch2
Set
swFeat = swSketch
'
Change the name of the open sketch to CircleSketch
swFeat.Name = "CircleSketch"
End Sub
'-------------------------------------