Page 1 of 1

How to extract configation name of a selected view with Macro ?

Posted: Tue Nov 14, 2023 8:11 am
by jeremyrz
Hello,

I'm looking for a macro capable of retrieving the name of the configuration used on a view previously selected by the user in a solidworks drawing.

Thanks for your help.

Re: How to extract configation name of a selected view with Macro ?

Posted: Tue Nov 14, 2023 9:46 am
by gupta9665
A view must be selected before you run the following macro

Code: Select all

Option Explicit
Sub main()
    Dim swApp As SldWorks.SldWorks
    Dim swModel As SldWorks.ModelDoc2
    Dim swSelMgr As SldWorks.SelectionMgr
    Dim swView As SldWorks.View
    Dim bRet As Boolean    
    
    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swSelMgr = swModel.SelectionManager
    Set swView = swSelMgr.GetSelectedObject6(1, -1)
    
    Debug.Print swView.ReferencedConfiguration
   
End Sub