几何尺寸与公差论坛

 找回密码
 注册
查看: 692|回复: 0

【转帖】save as pdf [resolved]

[复制链接]
发表于 2009-4-13 14:03:04 | 显示全部楼层 |阅读模式
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
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|几何尺寸与公差论坛

GMT+8, 2024-12-23 04:14 , Processed in 0.036500 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表