AnsweredAssumed Answered

Export PDF file with drawing name & revision

Question asked by Philip Ho on Mar 28, 2018
Latest reply on Apr 1, 2018 by Prasanna Ashok

Hello everyone, currently I want to export a PDF file with its drawing name & revision that is got custom property from the model rather than drawing's revision, in this case, my revision is "AMERev". My macro is working with the model but I'm still being stuck with drawing. What I should modify in this case, please advice and thank you so much for your attention.


     Here is my macro:

Option Explicit



    Public swApp                As SldWorks.SldWorks

    Dim swModel                 As SldWorks.ModelDoc2

    Dim swAssy                  As SldWorks.AssemblyDoc

    Dim swSheet                 As SldWorks.Sheet

    Dim swView                  As SldWorks.View

    Dim swDraw                  As SldWorks.DrawingDoc

    Dim vConfNameArr            As Variant

    Dim sConfigName             As String

    Dim sPath                   As String

    Dim sPath1                  As String

    Dim i                       As Long

    Dim bRebuild                As Boolean

    Dim bRet                    As Boolean

    Dim sRev                    As String

    Dim sPathName               As String

    Dim vSheetNames             As Variant

    Dim CurrentSheet            As String


Sub Main()




    Set swApp = CreateObject("SldWorks.Application")


    Set swModel = swApp.ActiveDoc


    '------------------------------------ swModel=2 => call swAssy-------------


    If swModel.GetType() = 2 Then


        Set swAssy = swModel


        sPathName = swAssy.GetPathName


        sPathName = Left(sPathName, Len(sPathName) - 7)


        sPath = UCase(Left(swAssy.CustomInfo2("", "AMERev"), 5))


        swAssy.SaveAs (sPathName & "_" & sPath & ".x_t")



    End If


    '------------------------------------- swModel=1 => call swModel------------


    If swModel.GetType() = 1 Then


        sPathName = swModel.GetPathName


        sPathName = Left(sPathName, Len(sPathName) - 7)


        sPath = UCase(Left(swModel.CustomInfo2("", "AMERev"), 5))


        swModel.SaveAs (sPathName & "_" & sPath & ".step")


    End If


    '-------------------------------------- swModel=3 => call swDraw------------


    If swModel.GetType() = 3 Then


        Set swDraw = swModel


        sPathName = swDraw.GetPathName


        sPathName = Left(sPathName, Len(sPathName) - 7)


        sPath = UCase(Left(swModel.CustomInfo2("", "AMERev"), 5))


        swDraw.SaveAs (sPathName & "_" & sPath & ".pdf")


    End If




End Sub