Hello, I have a setting that I need to apply for every assembly. Can this be done with a macro, or is there a general setting for it? Right-click on the general assembly, “Tree Display” - “Component Name and Description,” and in the window that opens, the boxes for 1-“Component Name”, 2-“Configuration Name”, and 4-“Do not show configuration or display state name if only one exists” should be checked, while 3-“Display state name” should be unchecked. I’m looking for a general setting or macro for this. Is there one available or can it be done? I am attaching screenshots as well.
It can most likely be done with a macro, I think I remember someone asking for something very similar.
See if #Task from Central Innovations does what you want. It is a very powerful set of tools for doing bulk manipulation of solidworks files. It is subscription based, but the cost is very reasonable.
I found the code
I’m sharing it below now. Thank you everyone.
'https://help.solidworks.com/2022/English/api/sldworksapi/SolidWorks.Interop.sldworks~SolidWorks.Interop.sldworks.IFeatureManager~HideComponentSingleConfigurationOrDisplayStateNames.html
'https://help.solidworks.com/2024/English/api/sldworksapi/SolidWorks.Interop.sldworks~SolidWorks.Interop.sldworks.IFeatureManager~SetComponentIdentifiers.html
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim Part As SldWorks.ModelDoc2
Dim swFeatMgr As SldWorks.FeatureManager
Dim compIdentifierRet As Long
Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Set swFeatMgr = Part.FeatureManager
If (swFeatMgr.ShowDisplayStateNames) Then
compIdentifierRet = swFeatMgr.SetComponentIdentifiers(swComponentIdentifier_ComponentName, 0, 0)
compIdentifierRet = swFeatMgr.SetComponentIdentifiers(swComponentIdentifier_ComponentDescription, 0, 0)
compIdentifierRet = swFeatMgr.SetComponentIdentifiers(swComponentIdentifier_ComponentName, 0, 0)
swFeatMgr.ShowComponentNames = True
swFeatMgr.ShowComponentDescriptions = False
swFeatMgr.ShowDisplayStateNames = False
swFeatMgr.HideComponentSingleConfigurationOrDisplayStateNames = True
swFeatMgr.ShowComponentConfigurationNames = True
swFeatMgr.ShowComponentConfigurationDescriptions = False
End If
End Sub
I like what this should do, but it doesn’t seem to do anything… is this pasted correctly?
[attachment=0]image.png[/attachment]
[/quote]

Many thanks for the macro. That’s terrific!
I have three macro’s i’ve used for a while that toggle the Display State Name/Configuration Name/Description in the FMT. I have each on a button to toggle easily. Unfort. the Description one seems to have broken in 2024 at some point and now it replaces the file name with the description instead of toggling it alongside the file name like it always did soi have yet to fix that. I’m sure its possible still, it just needs updating to work with their updated changes to this area. I just don’t have the patience or chance to fix it yet (I’m no programmer and only hack my way through getting them to work in the fist place).
This code you provide may give me some incite to correct mine when i get around to it, thanks.
Joined bc of this post. Great info to lead down the search path.
The problem for me was wanting to display Component Name as Primary and Component Description in Secondary. Using ShowComponentDescriptions true/false could not differentiate between primary and secondary.
Tree display how to.
limited old way
https://help.solidworks.com/2021/english/api/sldworksapi/Show_Components_and_Component_Configurations_Names_and_Descriptions_Example_VB.htm
The solution example
newer?? way with primary, secondary, tertiary accounted for
https://help.solidworks.com/2024/english/api/sldworksapi/SolidWorks.Interop.sldworks~SolidWorks.Interop.sldworks.IFeatureManager~SetComponentIdentifiers.html
Should be able to access all setting in the 3 levels this way.
So me the macro ended up being
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim File As SldWorks.ModelDoc2
Dim swFeatMgr As SldWorks.FeatureManager
Dim compIdentifierRet As Long
Sub main()
Set swApp = Application.SldWorks
Set File = swApp.ActiveDoc
Set swFeatMgr = File.FeatureManager
' Do show configuration or display state name if only one exists
swFeatMgr.HideComponentSingleConfigurationOrDisplayStateNames = False
'Set primary, secondary, and tertiary identifiers
compIdentifierRet = swFeatMgr.SetComponentIdentifiers(swComponentIdentifier_ComponentName, swComponentIdentifier_ConfigurationName + swComponentIdentifier_ComponentDescription, swComponentIdentifier_DisplayStateName)
End Sub
Keep in mind I copy pasta-d until it worked how I wanted from example sources.