×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Print Macro

Print Macro

Print Macro

(OP)
I'm in need a what i think is a fairly simple macro.  The macro would simply plot the drawing sheet to a prn file (check print to file box in the print dialog box)in the directory that the drawing file resides.  I went to record a macro to do this but once the print dialog box comes up solidworks can't record these steps anymore.  Any insight or help is much appreciated.  

Kind Regards,

RE: Print Macro

Try this macro - straight from the API help.

CODE

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

'

' Preconditions: Drawing document is open.

'

' Postconditions: Drawing document printed to file.

'

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

Option Explicit

Sub main()

    ' Printer

    Const SWPrinter     As String = "\\DOPEY\HP4100-TRAIN1"

    

    

    Dim swApp                   As SldWorks.SldWorks

    Dim swModel                 As SldWorks.ModelDoc2

    Dim swDocExt                As SldWorks.ModelDocExtension

    Dim swDraw                  As SldWorks.DrawingDoc

    

    Dim PathName                As String

    Dim PrintFileName           As String

    Dim nPrintSheets(1)         As Long

    Dim vPrintSheets            As Variant

    Dim DefPrinter              As String

    Dim i                       As Long

    

    Set swApp = Application.SldWorks

    Set swModel = swApp.ActiveDoc

    Set swDocExt = swModel.Extension

    Set swDraw = swModel

    

    ' Strip off SolidWorks file extension (.sldxxx)

    PathName = swModel.GetPathName

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

        

    For i = 0 To swDraw.GetSheetCount - 1

        ' Generate print filename based on sheet number

        ' For example, if drawing document is gears.slddrw and contains

        ' one sheet, then the print filename is gears0.prn

        PrintFileName = PathName & Trim(Str(i)) & ".prn"

        

        ' Print out one sheet at a time

        nPrintSheets(0) = i + 1

        vPrintSheets = nPrintSheets

        swDocExt.PrintOut2 (vPrintSheets), 1, False, SWPrinter, PrintFileName

    Next i

End Sub

RE: Print Macro

Check this link http://www.lennyworks.com/solidworks/default.asp?ID=20

There is a print drawing macro listed

Heckler
Sr. Mechanical Engineer
SWx 2007 SP 3.0 & Pro/E 2001
XP Pro SP2.0 P4 3.6 GHz, 1GB RAM
NVIDIA Quadro FX 1400
      o
  _`\(,_
(_)/ (_)

(In reference to David Beckham) "He can't kick with his left foot, he can't tackle, he can't head the ball and he doesn't score many goals. Apart from that, he's all right."  -- George Best

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources