I need to create 3d pdf from part and assembly. How to do it with API? I've tried the task scheduler but could not.
Thanks in advanced,
I run the code and the pdf has been created but i couldn't able to rotate the model in the pdf.
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
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).
Dim swApp As SldWorks.SldWorksDim swModel As ModelDoc2Dim lErrors As LongDim lWarnings As Long
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
This is the one I use. It will create a PFF in the directory that the model was opened from.
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:
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.
Check this by Matt: I've downloaded a SolidWorks macro from this or another site, but it has errors when I try to run it on my system. How can I fix this?
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!
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.
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.
Retrieving data ...