I currently have a Macro that successfully opens a part from a view on a drawing, takes information from that parts data card, and uses it to save both the part and the drawing with a custom name. Unfortunately, if that part has multiple configurations it doesn't necessarily open the correct configuration before extracting the data and outputting the file. I need a way to ensure the model configuration that's active is the configuration that appears in the drawing's view.
The code that I currently have to get my swModel set is:
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swDrawModel As SldWorks.ModelDoc2
Dim swDraw As SldWorks.DrawingDoc
Dim swView As SldWorks.View
Dim swConfig As SldWorks.Configuration
Dim swConfName As Variant
Dim BioNexPN As String
Dim swRev As String
Dim FilePath As String
Dim FileName As String
Dim PDF As String
Dim AdobePath As String
Dim Response As Integer
Dim bool As Boolean
'Set activive document as referenes
Set swApp = Application.SldWorks
Set swDrawModel = swApp.ActiveDoc
' Check to see if a drawing is loaded.
If swDrawModel Is Nothing Then
MsgBox "A released solidworks drawing must be open."
If swDrawModel.GetType <> swDocDRAWING Then
MsgBox "A solidworks drawing must be open and active to run this Macro."
'Define the OUTPUT file path
FilePath = Left(swDrawModel.GetPathName, InStrRev((swDrawModel.GetPathName), "\")) + "OUTPUT FILES\"
'Check if "OUTPUT FILES" folder exists
If FileOrDirExists(FilePath) = False Then
MsgBox "Please create 'OUTPUT FILES' sub folder"
'Get referenced 3D model
Set swDraw = swDrawModel
Set swView = swDraw.GetFirstView
Set swView = swView.GetNextView
Set swModel = swView.ReferencedDocument