![]() |
【转帖】save as pdf [resolved]
save as pdf [resolved]
i'm having trouble getting sw to save specified sheets only in a .pdf boolstatus = swexportpdfdata.setsheets(swexportdata_exportspecifiedsheets, drawingsheets) boolstatus = swmodeldocext.saveas(dexppath, 0, 0, swexportpdfdata, lerrors, lwarnings) that is the code i have... and the variant drawingsheets only contains one sheet name, yet when the macro exports the .pdf there are 2 sheets saved. ideas? if you want the rest of the code let me know and i will post it. edited: 09/04/2008 at 08:53 am by blake dahle blake, can you do something with this? filename = strings.left(filename, len(filename) - 6) & "pdf" boolstatus = swexportdata.setsheets(swexportdata_exportallsheets, 1) boolstatus = swmodeldocext.saveas(filename, 0, 0, swexportdata, lerrors, lwarnings) if boolstatus then all sheets are saved in 1 pdf, with the sheetnames in the overview. peka i'm trying to save the sheets seperately, but even though i specify the sheets it is including all sheets in the current document. i'm confused as to why... -.- just a reminder, 2009 will have this functionality built in for pdf and dxf, if i remember right. matt lorono solidworks 2007 sp3.1 cad engineer/ecn analyst originally posted by: matthew lorono just a reminder, 2009 will have this functionality built in for pdf and dxf, if i remember right. what will '09 have or do differently than what is available now? drc inc. minneapolis, mn .designreadycontrols.com sw2007 sp5.0 core2 quad 3gb ram xp pro sp2 ati firegl v3600 blake, i don't know what the rest of your code looks like, so i can't fully debug it. however, i was able to get the code below to work just fine exporting only sheets 2 & 3 (of 3). i did notice two things, though. 1) your variable storing what sheets to print should be a string, not a variant. i don't know why it matters, but when i use a variant it does the same thing as your macro and outputs all sheets instead of the sheets specified. 2) your swexportpdfdata object has the same name as the variable defining what type of export data to get in the swapp.getexportfiledata command. this gave me an error when trying to run the macro. dim swapp as sldworks.sldworks dim swpdfdata as exportpdfdata dim swdoc as modeldoc2 dim swdocext as modeldocextension dim strsheets(1) as string dim boolstatus as boolean dim lerrors as long dim lwarnings as long dim strpath as string sub main() set swapp = application.sldworks set swdoc = swapp.activedoc set swdocext = swdoc.extension set swpdfdata = swapp.getexportfiledata(swexportpdfdata) strpath = "c:\test.pdf" strsheets(0) = "sheet2" strsheets(1) = "sheet3" boolstatus = swpdfdata.setsheets(swexportdata_exportspecifiedsheets, strsheets) boolstatus = swdocext.saveas(strpath, 0, 0, swpdfdata, lerrors, lwarnings) end sub mahir abrahim, cswp/core. cswp/smtl mechanical design engineer sw 2009 sp2.1 proe wf3/4 thanks mahir. it does indeed need to be a string array in order to execute properly. this contradicts what the sw api help file says, but thats not that big of a surprise. appreciate the help. also, you are right that if declared as such it would error out: set swexportpdfdata = swapp.getexportfiledata(swexportpdfdata) however if you look at the example in the help, it can also be declared as: set swexportpdfdata = swapp.getexportfiledata(1) but again thanks for the help, and i do have my export working properly now. -blake d. quick |
所有的时间均为北京时间。 现在的时间是 07:25 PM. |