Michael Konyak

PDF Macro Pulling Info from Config Specific Property

Discussion created by Michael Konyak on May 30, 2019
Latest reply on May 30, 2019 by Michael Konyak

So I've been working on this for the last 2 days and can't seem to find the information anywhere.  All the Macros I have found online seem to pull the "Revision" from the Custom Properties of the part.  My macro needs to pull the "Revision" from the Configuration Specific Custom Property.  I can't seem to figure out how to get this to work.  Please help!


Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swDraw As SldWorks.DrawingDoc
Dim swCustProp As CustomPropertyManager
Dim valOut As String
Dim resolvedValOut As String
Dim Filepath As String
Dim FileName As String
Dim ConfigName As String

Sub main()

Set swApp = Application.SldWorks
Set swDraw = swApp.ActiveDoc

' Check to see if a drawing is loaded.

If (swDraw Is Nothing) Or (swDraw.GetType <> swDocDRAWING) Then

swApp.SendMsgToUser ("To be used for drawings only, Open a drawing first and then TRY!")

' If no model currently loaded, then exit

Exit Sub

End If

Set swView = swDraw.GetFirstView
Set swView = swView.GetNextView
Set swModel = swView.ReferencedDocument

ConfigName = swView.ReferencedConfiguration

Set swCustProp = swModel.Extension.CustomPropertyManager(Revision)

swCustProp.Get2 "Revision", valOut, resolvedValOut 'Change the custom property name here

Filepath = Left(swDraw.GetPathName, InStrRev(swDraw.GetPathName, "\"))

FileName = Left(swDraw.GetTitle, Len(swDraw.GetTitle) - 9)

swDraw.SaveAs (Filepath + FileName + "_" + resolvedValOut + ".PDF") 'Change the custom property text here

MsgBox "Drawing:" & Chr(13) & FileName & ".SLDDRW" & Chr(13) & Chr(13) & "With Revision:" & Chr(13) & resolvedValOut & Chr(13) & Chr(13) & "To location:" & Chr(13) & Filepath

End Sub