Save as PDF
Save as PDF
(OP)
Is there anyway to link the save as pdf option in the file --> Save As Pulldown to a button or something to make it a little faster to do?
Thanks
Chris Tellers
Thanks
Chris Tellers
When was the last time you drove down the highway without seeing a commercial truck hauling goods?
Download nowINTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS Come Join Us!Are you an
Engineering professional? Join Eng-Tips Forums!
*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail. Posting GuidelinesJobs |
|
RE: Save as PDF
¿)
RE: Save as PDF
Stefan Hamminga
EngIT Solutions
CSWP/Mechanical designer/AI student
RE: Save as PDF
Not follwoing you. Could you give me a little more detail?
Thanks
Chris Tellers
RE: Save as PDF
http://www.eng-tips.com/faqs.cfm?fid=530
Modify it to save as pdf instead (see SW API help).
Then you would assign a button to this macro (to run it straight from the toolbar) with the procedure I described.
Add a macro button to your toolbar:
1. know where you saved the macro
2. right click on the toolbar
3. choose 'customize'
4. choose the 'commands' tab
5. choose the 'macro' category
6. drag the most right button (the 'new macro button') to the desired location on the toolbar
7. a box pops up, fill in the required fields
That should do the trick
Stefan Hamminga
EngIT Solutions
CSWP/Mechanical designer/AI student
RE: Save as PDF
http://www.cadimensions.com/Resources/macros.cfm Simply put that macro on a button. PDF all sheets, or pick which sheet to pdf.
Flores
SW06 SP3.0
RE: Save as PDF
Helpful SW websites FAQ559-520
How to get answers to your SW questions FAQ559-1091
RE: Save as PDF
I am having no luck modifying the VBA to get it to work for the pdf.
Chris
RE: Save as PDF
1. Change "+" to "&"
2. Eliminate the portion that strips ".sldprt" from modname, since the extension is not returned by GetTitle for a drawing file
3. Add a backslash between MyPath and NewName in the SaveAs line
4. Update to SaveAs4 from SaveAs2
5. Use "Sldworks.Application" instead of CreateObject
CODE
Dim Model As SldWorks.ModelDoc2
Dim MyPath, ModName, NewName As String
Dim MB As Boolean
Dim Errs As Long
Dim Warnings As Long
' ********************************************************
' Save As Parasolid.swb - Recorded on 02/10/02 by Lee Bell
' Modified for SW2K6 by JB on 3/31/06
' ********************************************************
Sub main()
Set SwApp = Application.SldWorks
' This ensures that there are files loaded in SWX
Set Model = SwApp.ActiveDoc
If Model Is Nothing Then
MB = MsgBox("This routine requires files to be loaded before it is ran" & Chr(13) & _
"Please load a file and run the routine again", vbCritical)
Exit Sub
End
End If
' Use the current directory
MyPath = CurDir
' Or specify the directory you want to use
' Comment out the next line if you want to use the current directory
'MyPath = "C:\Where\Ever\Directory\You\Want\"
ModName = Model.GetTitle
NewName = ModName & ".pdf"
MsgBox "Saving " & NewName & " To" & Chr(13) & MyPath
MB = Model.SaveAs4(MyPath & "\" & NewName, swSaveAsCurrentVersion, swSaveAsOptions_Silent, Errs, Warnings)
If Not MB Then MsgBox "failed!"
Set Model = Nothing
'SwApp.CloseDoc ModName
End Sub
RE: Save as PDF
Thanks
Chris Tellers
RE: Save as PDF
Handleman
I cannot seem to get this Macro to work
Thanks
Chris Tellers
RE: Save as PDF
Any hints?
RE: Save as PDF
What kind of error messages are you getting?
Also, it doesn't currently save the file in the same directory as the drawing. It saves in the SolidWorks current directory, which is basically the directory that you last opened from or saved to. If you want to ensure that the PDF goes in the same directory, change the line
MyPath = CurDir
to
MyPath = Left(Model.GetPathName, InStrRev(Model.GetPathName, "\") - 1)
RE: Save as PDF
RE: Save as PDF
RE: Save as PDF
The only probelm is it does not come up with the dialog box to prompt you on which prints you want to print.
SolidWorks 2006 - SP 3.1
Thanks
Chris Tellers
RE: Save as PDF
"HKEY_CURRENT_USER\Software\Bluebeam Software\Pushbutton PDF\SolidWorksLt\WhatToPlot"
to toggle between printing single sheets and printing all sheets. This key does not exist on my machine. The macro at rhapsodydesignsolutions.com does not appear to give the option of separate files for sheets.
Sorry!
RE: Save as PDF
Thanks for all your help.
Chris Tellers
RE: Save as PDF
I tried restarting Solid Works as well as disabling and re-enabling the PDF add-in to no effect. It isn't imperative I have this function, but anything that might save me 5 seconds for every single time we export it might save hours on a long enough time line.
RE: Save as PDF
OK, maybe not. I do feel like that myself sometimes, though. Even/especially with stuff I write for my own use. Something screwy always comes up.
Check the value of Errs and Warnings immediately after the save, as in:
MB = SaveAs4.....
MsgBox "Errors: " & Errs & vbcrlf & "Warnings: " & Warnings
If either of these values is not zero then check the API help for their meaning.
You mentioned disabling/reenabling the PDF add-in. Did you have that prior to 2k6? I actually never used the PDF save option until I got 2k6, which was a fresh install on a new box. I don't have anything listed in my add-ins. I wonder if there's some sort of conflict between what the old add-in is trying to do and what the now built-in SW functionality is trying to do?
RE: Save as PDF
Thanks again, handleman--can't give you another star this week though.
RE: Save as PDF
CODE
in order to truncate that annoying little bit when passing it on to whomever is machining the part (or at least saving me the trouble of renaming it).
Figured someone else might find it helpful--I also suspect there is a setting in Solidworks that would directly remove that from being added to the filename. I wasn't sure, however, so I took the "easy" way out by doing a dirty job of removing the unwanted characters manually.
RE: Save as PDF
That last bit was exactly what I was looking for!!!
Now I had one other thing I would like to accomplish. We add the Revision letter to the pdf file name: "PartnumberRev.pdf". So in our part properties we have a custom property that is "Revision". When pdf'ing out the drawing, I would like to pull that info from the part file and add it to the "getfile" info so it would look like the example I showed above. Any suggestions or ideas???
Thank You
RE: Save as PDF
IDontCare is a "dummy" variable (you can declare it as a Variant) that OpenDoc6 loads with some information that I can't remember what it is and never cared, hence the name.
CODE
out = 0
While swView.GetReferencedModelName = ""
Set swView = swView.GetNextView
out = out + 1
If out = 10 Then Exit Sub
If swView Is Nothing Then Exit Sub
Wend
sRefModelName = swView.GetReferencedModelName 'get name of referenced part
If swView.IsModelLoaded = False Then
swView.LoadModel 'load the model if it ain't
End If
Set TargetPart = swApp.OpenDoc6(sRefModelName, swDocASSEMBLY, swOpenDocOptions_Silent, "", IDontCare, IDontCare) 'activate the part
sPartNum = TargetPart.CustomInfo2("", "Part_Number")
RE: Save as PDF
If swView.IsModelLoaded = False Then
with
If Not swView.IsModelLoaded Then
It works for me as-is, but the second way is preferred. At least I'm pretty sure it is. Maybe someone who knows proper programming can weigh in.
RE: Save as PDF
RE: Save as PDF
Dim swDocType As Long
Dim sRefModelName As String
Dim swDrawing As SldWorks.DrawingDoc
Dim swView As SldWorks.View
Dim TempModelName As String
Dim IDontCare As Long
Dim out as Integer
Dim TargetPart as SldWorks.ModelDoc2
Dim sPartNum as String
Then, add a couple of lines to the last bit of code. I've reposted it below with the additional lines. The additions are the leading IF statement and the line
Set swView = Model
CODE
Set swDrawing = Model
Set swView = swDrawing.GetFirstView
out = 0
While swView.GetReferencedModelName = ""
Set swView = swView.GetNextView
out = out + 1
If out = 10 Then Exit Sub
If swView Is Nothing Then Exit Sub
Wend
sRefModelName = swView.GetReferencedModelName 'get name of referenced part
If Not swView.IsModelLoaded Then
swView.LoadModel 'load the model if it ain't
End If
Set TargetPart = swApp.OpenDoc6(sRefModelName, swDocASSEMBLY, swOpenDocOptions_Silent, "", IDontCare, IDontCare) 'activate the part
sPartNum = TargetPart.CustomInfo2("", "Part_Number")
End If
RE: Save as PDF
Here is my test VB 6 code:
Private swApp As SldWorks.SldWorks
Private swMdl As SldWorks.ModelDoc2
Private Sub Command1_Click()
Dim sPath As String
Dim sName1 As String, sName2 As String, sName3 As String
Dim sFile As String, sPDF As String, swExt As String
sPath = "D:\Test1\Solidworks\"
sName1 = "E00234-0000-D"
sName2 = "E00235-0000-D"
sName3 = "E00236-0000-D"
swExt = ".SLDDRW"
Set swApp = New SldWorks.SldWorks
swApp.Visible = True
For i = 0 To 2
Select Case i
Case 0
sFile = sPath & sName1 & swExt
sPDF = sPath & sName1 & ".pdf"
Case 1
sFile = sPath & sName2 & swExt
sPDF = sPath & sName2 & ".pdf"
Case 2
sFile = sPath & sName3 & swExt
sPDF = sPath & sName3 & ".pdf"
End Select
Dim oe As Long, ow As Long
Set swMdl = swApp.OpenDoc6(sFile, 3, 32 Or 1, "", oe, ow)
Dim bRes As Boolean, se As Long, sw As Long
bRes = swMdl.SaveAs4(sPDF, 0, 0, se, sw)
MsgBox "File = " & sFile & vbCr & "PDF = " & sPDF & vbCr & _
"Open Error = " & oe & vbCr & "Open Warning = " & ow & vbCr & _
"Result = " & bRes & vbCr & "Save Error = " & se & vbCr & _
"Save Warning = " & sw
Next
swApp.ExitApp
End Sub
variable se is returning 256 and bRes is returning False when I test in VB 6, but works great in macro.
Thanks.