Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB/SolidWorks printing to distiller 1

Status
Not open for further replies.

jh0401

Computer
Apr 8, 2002
32
US
Does anyone have a nice example of printing a SolidWorks drawing to Adobe Acrobat distiller?

How about saving "ImAdrawing.SLDDRW" to the desktop?

Thanks,
Josh
 
Replies continue below

Recommended for you

I'M HAVING PROBLEMS GETTING EITHER ACROBAT DISTILLER OR ACROBAT PDFWRITER TO PRINT PDF FILES TO A SPECIFIC LOCATION OR PRINT AT ALL USING VB TO DRIVE SOLIDWORKS. NO PROBLEMS WHEN I PRINT TO EITHER THROUGH THE SOLIDWORKS TOOLBAR. I CAN USE VB TO MAKE SOLIDWORKS PRINT TO ANY OTHER OF THE PRINTERS, BUT NOT PDF TO FILE. IF ANYONE HAS A GOOD EXAMPLE I WOULD GREATLY APPRECIATE IT. THE EXAMPLE IN THE SOLIDWORKS API IS NOT WORKING FOR SOME REASON. HOPEFULLY I'M JUST MISSING SOMETHING SIMPLE.

THANKS
JOSH
 

Here's the code to get SolidWorks to make a PDF file in the same location as SolidWorks drawing if anyone is interested.

Put this in a module and call from VB app:

GENERAL DECLARATIONS
Option Explicit
Const vbPRORPortrait As Long = 1
Const vbPRORLandscape As Long = 2
Const vbPRPSLetter As Long = 1
Const vbPRPSLetterSmall As Long = 2
Const vbPRPSTabloid As Long = 3
Const vbPRPSLedger As Long = 4
Const vbPRPSLegal As Long = 5
Const vbPRPSStatement As Long = 6
Const vbPRPSExecutive As Long = 7
Const vbPRPSA3 As Long = 8
Const vbPRPSA4 As Long = 9
Const vbPRPSA4Small As Long = 10
Const vbPRPSA5 As Long = 11
Const vbPRPSB4 As Long = 12
Const vbPRPSB5 As Long = 13
Const vbPRPSFolio As Long = 14
Const vbPRPSQuarto As Long = 15
Const vbPRPS1_H14 As Long = 16
Const vbPRPS11x17 As Long = 17
Const vbPRPSNote As Long = 18
Const vbPRPSEnv9 As Long = 19
Const vbPRPSEnv10 As Long = 20
Const vbPRPSEnv11 As Long = 21
Const vbPRPSEnv12 As Long = 22
Const vbPRPSEnv14 As Long = 23
Const vbPRPSCSheet As Long = 24
Const vbPRPSDSheet As Long = 25
Const vbPRPSESheet As Long = 26
Const vbPRPSEnvDL As Long = 27
Const vbPRPSEnvC3 As Long = 29
Const vbPRPSEnvC4 As Long = 30
Const vbPRPSEnvC5 As Long = 28
Const vbPRPSEnvC6 As Long = 31
Const vbPRPSEnvC65 As Long = 32
Const vbPRPSEnvB4 As Long = 33
Const vbPRPSEnvB5 As Long = 34
Const vbPRPSEnvB6 As Long = 35
Const vbPRPSEnvItaly As Long = 36
Const vbPRPSEnvMonarch As Long = 37
Const vbPRPSEnvPersonal As Long = 38
Const vbPRPSFanfoldUS As Long = 39
Const vbPRPSFanfoldStdGerman As Long = 40
Const vbPRPSFanfoldLglGerman As Long = 41
Const vbPRPSUser As Long = 256
' Defined in swconst.bas
Const swPrintPaperSize As Long = 0
Const swPrintOrientation As Long = 1
Const SWPrinter As String = "Acrobat PDFWriter"



Sub PDF()
Dim swApp100 As Object 'SldWorks.SldWorks
Dim swModel100 As Object 'SldWorks.ModelDoc2
Dim swDrwDoc As Object 'SldWorks.DrawingDoc
Dim swSheet As Object 'SldWorks.sheet
Dim NumSheet As Long
Dim PathName As String
Dim PrintFileName As String
Dim SheetName As String
Dim Errors As Long
Dim i As Long

Set swApp100 = CreateObject("SldWorks.Application")
Set swModel100 = swApp100.ActiveDoc
Set swDrwDoc = swModel100

' strip off SolidWorks file extension (.sld???)
PathName = swModel100.GetPathName
PathName = Left(PathName, Len(PathName) - 7)

'go back to the first sheet
NumSheet = swDrwDoc.GetSheetCount
For i = 0 To NumSheet - 1
swDrwDoc.SheetPrevious
Next i


For i = 0 To NumSheet - 1
' generate print filename based on sheet number
PrintFileName = PathName + "_Sheet-" + Trim(Str(i))
swDrwDoc.ForceRebuild
swModel100.PrintOut2 i + 1, i + 1, 1, False, SWPrinter, 0#, True, PrintFileName
swDrwDoc.SheetNext
Next i

Set swDrwDoc = Nothing

End Sub



Thanks,

Josh
 
I forgot to mention that you have to have Adobe Acrobat 5.0 and not just Adobe Reader to print to either the Adobe Distiller(for more detail) or Adobe PDFWriter(for mainly text documents).

Thanks,

Josh
 
Excellent solution! DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top