Can I rename the API name of a detail view with API?

I would like to rename  my detail view with the same name found in the FeatureManager.

 

From my recording I can see that the name is "Drawing View19"

I would very like that name to be something of my choosing. Is that possible with API?

 

Answers 3
PP
PP 2025-08-13

Hello Lasse,

You can use the below code.

Dim swApp As Object
Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Dim swView As View
Dim swSelMgr As SldWorks.SelectionMgr
Sub main()
    Set swApp = Application.SldWorks
    Set Part = swApp.ActiveDoc
    boolstatus = Part.Extension.SelectByID2("Drawing View19", "DRAWINGVIEW", 0, 0, 0, False, 0, Nothing, 0)
    Set swSelMgr = Part.SelectionManager
    Set swView = swSelMgr.GetSelectedObject6(1, -1)
    boolstatus = swView.SetName2("Your_Desired_Name")
    Debug.Print (boolstatus)
End Sub
LN
LN 2025-08-13

Hi Programming Zombie PZ,

 

Thank you very much for your time. Unfortunately this didn't work.

From my experience SetName2 only works for view that you can manually rename in the FeatureManager. 

Detail Views and Section Views are special cases that are automatically named in the FeatureManager. This also mean that their API names have these random names 😟 

 

A similar situation can be said for drawing dimension that you manually add directly on a drawing. They have names in the form of "RD1" and "RD2" etc. From the GUI it is impossible to change these names as the field is greyed out. 

But these you can rename using API ( swDim.name = "YourName") 

 

comment imagecomment image
DG
DG 2025-08-13

Check the macro codes by @AT in the below post