Valdas K.

Renaming all subassembly component configuration Macro

Discussion created by Valdas K. on Sep 13, 2020
Latest reply on Oct 8, 2020 by Valdas K.

I want to write a macro, that can iterate and rename main configurations (not sub configurations).
I wrote a code, form examples I found. It works. but it renames all configurations sequentially. Is it possible to skip Flat patterns and sub configurations?

and making it run from assembly as well?

 

 

 

Option Explicit

Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim vConfNameArr As Variant

Dim i As Long

Dim swConfig As SldWorks.Configuration

 

Sub main()

Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc

vConfNameArr = swModel.GetConfigurationNames

For i = 0 To UBound(vConfNameArr)

Set swConfig = swModel.GetConfigurationByName(vConfNameArr(i))

Dim CountA As String

CountA = "_" & i

swConfig.Name = Left(swModel.GetTitle, Len(swModel.GetTitle)) & Right(swConfig.Name, 0) & CountA

 

Next i


End Sub

Outcomes