5 Replies Latest reply on Mar 19, 2011 2:50 PM by Deepak Gupta

    Export with Task Scheduler with Revision

    Matt Jacobs

      Is there a option to export dwg/dxf with the revision level as an extension of the file name?  I'm looking to do a batch export but would like to know the revision without having to open the drawing.

       

      Thanks

       

      Matt

        • Re: Export with Task Scheduler with Revision
          Deepak Gupta

          Matt, I'm not sure if Task Scheduler can help (if it can I don't know how) but yes you can use a macro to do it (provided you have the revision property in the file custom properties)

           

          Check the macro in this post: Re: Custom Property into the following macro (change PDF to dwg/dxf )

            • Re: Export with Task Scheduler with Revision
              Matt Jacobs

              Deepak

               

              I used the macro from the other thread, and modified the custom property to match our templates, but I was not able to get the correct script to have it save as a dwg. Here is my modified macro

               

              Option Explicit
                      Dim swApp               As SldWorks.SldWorks
                      Dim swModel             As SldWorks.ModelDoc2
                      Dim swModelDocExt       As SldWorks.ModelDocExtension
                      Dim swExportData        As SldWorks.ExportDWGData
                      Dim swCustPrpMgr        As SldWorks.CustomPropertyManager
                      Dim boolstatus          As Boolean
                      Dim filename            As String
                      Dim lErrors             As Long
                      Dim lWarnings           As Long
                      Dim Value               As String
                  Sub main()
                      Set swApp = Application.SldWorks
                      Set swModel = swApp.ActiveDoc
                      If swModel Is Nothing Then
                          MsgBox "No current document", vbCritical
                          End
                      End If
                      If swModel.GetType <> swDocDRAWING Then
                          MsgBox "This Macro only works on Drawings", vbCritical
                          End
                      End If
                      Set swModelDocExt = swModel.Extension
                    
                      Set swExportData = swApp.GetExportFileData(swExportDWGData)
                    
                      filename = swModel.GetPathName
                    
                      If filename = "" Then
                    
                          MsgBox "Please save the file first and try again", vbCritical
                          End
                      End If
                    
                      Set swCustPrpMgr = swModel.Extension.CustomPropertyManager("")
                   
                    'Get Custom Property
                  
                     swCustPrpMgr.Get3 "REVISION", False, "", Value
                   
                      filename = Strings.Left(filename, Len(filename) - 7) & "_" & Value & ".DWG"
                    
                      boolstatus = swExportData.SetSheets(swExportData_ExportAllSheets, 1)
                    
                      boolstatus = swModelDocExt.SaveAs(filename, 0, 0, swExportData, lErrors, lWarnings)
                    
                    
                      If boolstatus Then
                          MsgBox "Save as DWG successful" & vbNewLine & filename
                     Else
                          MsgBox "Save as DWG failed, Error code:" & lErrors
                      End If
                      Set swApp = Nothing
                      Set swModel = Nothing
                      Set swModelDocExt = Nothing
                     Set swExportData = Nothing
                  End Sub

               

              Let me know what I need to change so it will save as a dwg file format

               

              Thanks

                • Re: Export with Task Scheduler with Revision
                  Deepak Gupta

                  Try this

                   

                   

                  Option Explicit
                          Dim swApp               As SldWorks.SldWorks
                          Dim swModel             As SldWorks.ModelDoc2
                          Dim swCustPrpMgr        As SldWorks.CustomPropertyManager
                          Dim boolstatus          As Boolean
                          Dim filename            As String
                          Dim lErrors             As Long
                          Dim lWarnings           As Long
                          Dim Value               As String
                      Sub main()
                          Set swApp = Application.SldWorks
                          Set swModel = swApp.ActiveDoc
                          If swModel Is Nothing Then
                              MsgBox "No current document", vbCritical
                              End
                          End If
                          If swModel.GetType <> swDocDRAWING Then
                              MsgBox "This Macro only works on Drawings", vbCritical
                              End
                          End If
                         
                          filename = swModel.GetPathName
                        
                          If filename = "" Then
                        
                              MsgBox "Please save the file first and try again", vbCritical
                              End
                          End If
                        
                          Set swCustPrpMgr = swModel.Extension.CustomPropertyManager("")
                       
                        'Get Custom Property
                      
                         swCustPrpMgr.Get3 "REVISION", False, "", Value
                       
                          filename = Strings.Left(filename, Len(filename) - 7) & "_" & Value & ".DWG"
                        
                          boolstatus = swModel.SaveAs3(filename, 0, 0)
                        
                          Set swApp = Nothing
                          Set swModel = Nothing
                  End Sub