Batch Printing

Discussion in 'SolidWorks' started by Brian & Patty, Oct 10, 2003.

  1. Hi Group,

    I'm currently using 2001+ at work and was wondering if there was a
    free-ware program to print multiple drawings all at once? I have seen a
    couple of programs you can purchase but seems to me that this is an
    elementary program.

    Thanks in advance,

    Brian
     
    Brian & Patty, Oct 10, 2003
    #1
  2. Brian & Patty

    xbow man Guest

    Or some simple code like the following - in a macro script - would work ok
    for $0 and a some time to adjust any of the code to work for you depending
    how much experience you have editing VB. I am supplying this at your own
    risk; although it does work for me. You'll need to set the directory in the
    code and make sure you end the directory with a backslash. You will also
    need to print at least one document with the settings you want before
    running the macro. It also helps to have the "Print Preview" box checked in
    your print dialog box for the first time you run it that way you can always
    cancel.



    Copy and paste into a new macro.



    Option Base 1

    Dim swApp As Object

    Dim longstatus As Long



    Sub main()



    Dim Part As Object

    Dim Drawing As Object

    Dim boolstatus As Boolean

    Dim Annotation As Object

    Dim Gtol As Object

    Dim DatumTag As Object

    Dim FeatureData As Object

    Dim Feature As Object

    Dim Component As Object

    Dim ModelDoc2 As Object

    Dim sPathName As String

    Dim nErrors As Long

    Dim nWarnings As Long

    Dim nRetval As Long

    Dim bShowMap As Boolean

    Dim bRet As Boolean

    Dim CurrentFile As String 'Declaring Var for file being parsed

    Dim TheFiles() As Variant 'Declaring dynamic array for holding found drawing
    files

    Dim FilePath As String

    Dim FileName As String

    Set swApp = CreateObject("SldWorks.Application") 'Attaching to SolidWorks



    n = 1

    FilePath = "D:\dir1\dir2\dir3\" 'type correct drive and directory name

    ReDim Preserve TheFiles(n) 'Resizing dynamic array as
    data is captured

    CurrentFile = Dir(FilePath & "*.slddrw") 'Getting name of first
    drawing file

    TheFiles(n) = CurrentFile 'adding first drawing to
    array

    Do While CurrentFile <> "" 'Setting up loop to capture all
    remaining drawings

    CurrentFile = Dir 'Getting next drawing in the
    directory selected

    If CurrentFile = "" Then

    Exit Do

    Else

    n = n + 1 'incrementing counter

    ReDim Preserve TheFiles(n) 'Resizing the array
    while preserving the contents

    TheFiles(n) = CurrentFile 'Adding next drawing to
    array

    End If

    If n > 200 Then Exit Do 'Get out of jail free statement

    Loop



    n = UBound(TheFiles) 'Setting n to total place holders in the array



    For n = UBound(TheFiles) To LBound(TheFiles) Step -1 'setting For-Next Loop





    '---------------------------------------------------------------------------
    -----------

    'Starting to open drawing files

    longstatus = 1

    ' Set ModelDoc2 = swApp.OpenDoc4(FilePath & TheFiles(n), 3, 0, "",
    longstatus) 'Opening the first drawing in SW

    Set ModelDoc2 = swApp.OpenDoc3(FilePath & TheFiles(n), 3, True, True,
    False, True, longstatus) 'Opening the first drawing in SW

    ModelDoc2.Visible = False 'for faster proscessing we hide the object

    Set ModelDoc2 = swApp.ActiveDoc ' Grab the currently active document





    ' Numsheets = ModelDoc2.GetSheetCount() 'Getting total drawing sheets
    count from drawing



    ' Setup the printer and print

    Dim printer As String

    printer = "EPSON Stylus COLOR 777"



    swApp.ActivePrinter = printer



    ModelDoc2.PrintOut2 1, Numsheets, 1, False, printer, 0#, False, "x"



    ' Set ModelDoc2 = Nothing

    swApp.CloseDoc (TheFiles(n)) 'close drawing

    longstatus = 1



    Next

    End Sub









     
    xbow man, Oct 11, 2003
    #2
  3. Brian & Patty

    xbow man Guest

    Or some simple code like the following - in a macro script - would work ok for $0 and a some time to adjust any of the code to work
    for you depending how much experience you have editing VB. I am supplying this at your own risk; although it does work for me.
    You'll need to set the directory in the code and make sure you end the directory with a backslash. You will also need to print at
    least one document with the settings you want before running the macro. It also helps to have the "Print Preview" box checked in
    your print dialog box for the first time you run it that way you can always cancel.



    Copy and paste into a new macro.



    Option Base 1

    Dim swApp As Object

    Dim longstatus As Long



    Sub main()



    Dim Part As Object

    Dim Drawing As Object

    Dim boolstatus As Boolean

    Dim Annotation As Object

    Dim Gtol As Object

    Dim DatumTag As Object

    Dim FeatureData As Object

    Dim Feature As Object

    Dim Component As Object

    Dim ModelDoc2 As Object

    Dim sPathName As String

    Dim nErrors As Long

    Dim nWarnings As Long

    Dim nRetval As Long

    Dim bShowMap As Boolean

    Dim bRet As Boolean

    Dim CurrentFile As String 'Declaring Var for file being parsed

    Dim TheFiles() As Variant 'Declaring dynamic array for holding found drawing files

    Dim FilePath As String

    Dim FileName As String

    Set swApp = CreateObject("SldWorks.Application") 'Attaching to SolidWorks



    n = 1

    FilePath = "D:\dir1\dir2\dir3\" 'type correct drive and directory name

    ReDim Preserve TheFiles(n) 'Resizing dynamic array as data is captured

    CurrentFile = Dir(FilePath & "*.slddrw") 'Getting name of first drawing file

    TheFiles(n) = CurrentFile 'adding first drawing to array

    Do While CurrentFile <> "" 'Setting up loop to capture all remaining drawings

    CurrentFile = Dir 'Getting next drawing in the directory selected

    If CurrentFile = "" Then

    Exit Do

    Else

    n = n + 1 'incrementing counter

    ReDim Preserve TheFiles(n) 'Resizing the array while preserving the contents

    TheFiles(n) = CurrentFile 'Adding next drawing to array

    End If

    If n > 200 Then Exit Do 'Get out of jail free statement

    Loop



    n = UBound(TheFiles) 'Setting n to total place holders in the array



    For n = UBound(TheFiles) To LBound(TheFiles) Step -1 'setting For-Next Loop





    '--------------------------------------------------------------------------------------

    'Starting to open drawing files

    longstatus = 1

    ' Set ModelDoc2 = swApp.OpenDoc4(FilePath & TheFiles(n), 3, 0, "", longstatus) 'Opening the first drawing in SW

    Set ModelDoc2 = swApp.OpenDoc3(FilePath & TheFiles(n), 3, True, True, False, True, longstatus) 'Opening the first drawing in SW

    ModelDoc2.Visible = False 'for faster proscessing we hide the object

    Set ModelDoc2 = swApp.ActiveDoc ' Grab the currently active document





    ' Numsheets = ModelDoc2.GetSheetCount() 'Getting total drawing sheets count from drawing



    ' Setup the printer and print

    Dim printer As String

    printer = "EPSON Stylus COLOR 777"



    swApp.ActivePrinter = printer



    ModelDoc2.PrintOut2 1, Numsheets, 1, False, printer, 0#, False, "x"



    ' Set ModelDoc2 = Nothing

    swApp.CloseDoc (TheFiles(n)) 'close drawing

    longstatus = 1



    Next

    End Sub









     
    xbow man, Oct 11, 2003
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.