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

Library for macros
jeremyrz
Posts: 8
Joined: Thu Nov 02, 2023 11:22 am
Answers: 0

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

Unread post 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.
User avatar
gupta9665
Posts: 410
Joined: Thu Mar 11, 2021 10:20 am
Answers: 25
Location: India
x 433
x 449

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

Unread post 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
Deepak Gupta
SOLIDWORKS Consultant/Blogger
Post Reply