-
Re: How to create 3d pdf automatically?
AMCBridge eXperts Mar 17, 2010 3:19 AM (in response to Novly Abdurohman)1) Get the IExportPdfData object using ISldWorks::GetExportFileData.2) Set the export as 3D option using ExportPdfData::ExportAs3D property.3) Call IModelDocExtension::SaveAs after setting this property.________________________________________________________________SolidWorks API Tips & Tricks: http://amcbridge.com/?q=SolidWorksApiBlog -
Re: How to create 3d pdf automatically?
Luke Malpass Mar 17, 2010 6:10 AM (in response to Novly Abdurohman)Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As ModelDoc2
Dim lErrors As Long
Dim lWarnings As Long
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Dim exportData As Object: Set exportData = swApp.GetExportFileData(swExportPdfData)
swModel.Extension.SaveAs "C:\the3Dfile.pdf", swSaveAsCurrentVersion, swSaveAsOptions_Silent, exportData, lErrors, lWarnings
End Sub-
Re: How to create 3d pdf automatically?
sandeep pawar Mar 17, 2010 1:24 PM (in response to Luke Malpass)Hi luke,
I run the code and the pdf has been created but i couldn't able to rotate the model in the pdf.
-
Re: How to create 3d pdf automatically?
Dan Miel Mar 17, 2010 1:34 PM (in response to Luke Malpass)I modified line nine and added the next line. It should work.
Dim exportData As SldWorks.ExportPdfData: Set exportData = swApp.GetExportFileData(swExportPdfData)
exportData.ExportAs3D = True-
Re: How to create 3d pdf automatically?
sandeep pawar Mar 17, 2010 3:08 PM (in response to Dan Miel)THAT WORKED!! -
Re: How to create 3d pdf automatically?
Luke Malpass Mar 18, 2010 3:54 AM (in response to Dan Miel)Thought I typed that line, lol. Good catch.
-
-
Re: How to create 3d pdf automatically?
1-40YOS4 Aug 4, 2010 2:17 PM (in response to Luke Malpass)Hi! I never worked programming macros before.
Can anyone help me with this?
I'm getting this error (see image attached).
The macro I created (copyied from this topic...lol) is attached also (Macro1.swp).
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As ModelDoc2
Dim lErrors As Long
Dim lWarnings As LongSub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Dim exportData As SldWorks.ExportPdfData: Set exportData = swApp.GetExportFileData(swExportPdfData)
exportData.ExportAs3D = True
swModel.Extension.SaveAs "C:\the3Dfile.pdf", swSaveAsCurrentVersion, swSaveAsOptions_Silent, exportData, lErrors, lWarnings
End Sub
-
Macro1.swp.zip 6.1 KB
-
Re: How to create 3d pdf automatically?
Dan Miel Aug 4, 2010 3:55 PM (in response to 1-40YOS4)This is the one I use. It will create a PFF in the directory that the model was opened from.
Dan Miel
-
Create Single 3D PDF.zip 14.1 KB
-
Re: How to create 3d pdf automatically?
1-40YOS4 Aug 4, 2010 5:28 PM (in response to Dan Miel)Thanks Dan!
But it didn't work for me. Am I doing something wrong?
These are the steps I followed:
I saved your macro on D:/
Than I opened Solidworks, opened a .sldpart model and clicked on Macro>Run
It began running but it gave this error:
"Compilation Error: It's impossible to find the project or library"
Then I click [OK] and it shows this screen:
-
Re: How to create 3d pdf automatically?
Dan Miel Aug 4, 2010 5:50 PM (in response to 1-40YOS4)I am using SW2009, if you are using 2010 or something older you may need to change your references. You do this by going to the menu bar and clicking “Tools>References”. If the list has a message saying missing then uncheck that reference and select one just like it but with the year of your SolidWorks.
Dan
SW2009
-
-
Re: How to create 3d pdf automatically?
1-40YOS4 Aug 12, 2010 12:49 PM (in response to Deepak Gupta)Thanks Dan and Deepak!
I understood the concept of changing the library for my Solidworks version but I couldn't find and replace all of them, so I kept receiving the same errors.
But now I'm negociating with our engineer supervisor the possibility to update our Solidworks license. And it will no longer be a problem for us anymore.
Thanks again, learned a lot!
-
Re: How to create 3d pdf automatically?
Dan Miel Aug 12, 2010 2:00 PM (in response to 1-40YOS4)Rafael if you change the line “Part.Extension.SaveAs FileName, swSaveAsCurrentVersion, swSaveAsOptions_Silent, swExportPDFData, lErrors, lWarnings” to “Part.Extension.SaveAs FileName, 0, 1, swExportPDFData, lErrors, lWarnings” then the only two references you need are SolidWorks Extensibility Type library and SldWorks 2009 Type Library.
Also this code did not become available until 2007 SP1 so if you have 2006 the code will not run.
Dan Miel
2009 SSP4
-
Re: How to create 3d pdf automatically?
Deepak Gupta Aug 12, 2010 10:35 PM (in response to 1-40YOS4)It's good as you going to upgrade, hence fixing the problem.
BTW sometimes copying and pasting the codes in a new macros works too.
-
-
-
-
-
-