几何尺寸与公差论坛

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

【转帖】save as .pdf options

[复制链接]
发表于 2009-4-12 22:17:22 | 显示全部楼层 |阅读模式
save as *.pdf options
hello,
i'm preparing an application for saving a pdf file from a drawing.
i've written this code and works:
retval = modelo.saveas4(nuevonombre, 0, swsaveasoptions_silent, 0, 0)
the problem is i have more than 1 sheet and always saves all the sheets in 1 pdf file.
does anybody know how to save only the active sheet?
thanks.
mikel,
there was another thread on exactly the same subject only a few weeks ago. try to search for it.
jorn bjarning
cswp
cad & plm consultant
sw2008 sp5 / sw2009 sp2
jorn,
could you tell me where can i find the options for configuring the "saveas4/3..."
code? i mean, the options between parenthesis:
retval = modelo.saveas4(nuevonombre, 0, swsaveasoptions_silent, 0, 0)
i can't find it into the sw api help.
thanks a lot.
swsaveasversion_e
specifies in which version of a particular format the document should be saved.
swsaveascurrentversion - this is the typical save behavior.
swsaveasformatproe
swsaveasstandarddrawing
swsaveasdetacheddrawing
swsaveasoptions_e
swsaveasoptions_silent
swsaveasoptions_copy
swsaveasoptions_savereferenced //supports parts, assemblies, and drawings. this setting indicates to save all components (sub-assemblies and parts) in both assemblies and drawings. if a part has an external reference, then this setting indicates to save the external reference.
swsaveasoptions_avoidrebuildonsave
swsaveasoptions_updateinactiveviews //not a valid option for partdoc::savetofile2. this setting is only applicable for a drawing that has one or more sheets. this setting updates the views on inactive sheets.
swsaveasoptions_overridesaveemodel //saves edrawings-related information into a section of the file being saved. specifying this setting overrides the tools, options, system options, general, save edrawings data in solidworks document setting. not a valid option for partdoc::savetofile2.
swsaveasoptions_saveemodeldata //obsolete
swsaveasoptions_detacheddrawing //not a valid option for partdoc::savetofile2
note: these options only apply to saving to native solidworks file formats. for example, to export a solidworks file to a vrml file format, use sldworks::getuserpreferencetoggle and sldworks::setuserpreferencetoggle with swexportvrmlallcomponentsinsinglefile
mikel,
saveas4 is obsolete. you should use modeldocextension::saveas instead. in the help you have links explaining the options.
jorn bjarning
cswp
cad & plm consultant
sw2008 sp5 / sw2009 sp2
luke,
i found one of your topics and there appears you solve the problem with:
retval = swexportdata.setsheets(swexportdata_exportallsheets, 1)
but how did you configured for exporting only the active sheet?
thanks a lot,
mikel arrasate
here is my solution that i use on a daily basis. it creates a pdf of a file and places it into a specific network folder based upon some checkboxes. it then looks at the sheet name and exports a pdf of only the sheet requested.
code:
dim swprog as sldworks.sldworks
dim swmodel as sldworks.modeldoc2
dim swmodeldocext as sldworks.modeldocextension
dim swexportpdfdata as sldworks.exportpdfdata
dim selmgr as object
dim boolstatus as boolean
dim longstatus as long, longwarnings as long
dim feature as object
dim filename as string
dim filename2 as string
dim sprintdir as string
dim strsheetname as string
dim varsheetname as variant
dim spdirlength as integer
private sub cmddoit_click()
'on error goto err
if chksprint = true then
call sprint
end if
if chktprint = true then
call tprint
end if
if chkiprint = true then
call iprint
end if
frmprintpdf.hide
unload frmprintpdf
exit sub
err:
resume
end sub
private sub sprint()
set swprog = application.sldworks
swprog.visible = true
set part = swprog.activedoc
set selmgr = part.selectionmanager
set swmodeldocext = part.extension
set swexportpdfdata = swprog.getexportfiledata(1)
strsheetname = "s-print"
sprintdir = "\\lexp-jasper\tech\eng\cad_files\solidworks\s-prints\"
spdirlength = len(sprintdir)
filename = part.getpathname
filename = left(filename, len(filename) - 6)
filename = right(filename, len(filename) - spdirlength)
filename2 = "\\lexp-jasper\tech\eng\master\sales_cd\s-prints\" & filename & "pdf"
if chkmold = true then
varmoldnum = txtmold.value
if dir("\\lexp-jasper\tech\eng\cad_files\part_prints\" & varmoldnum & "\", vbdirectory) = "" then
mkdir "\\lexp-jasper\tech\eng\cad_files\part_prints\" & varmoldnum & "\"
mkdir "\\lexp-jasper\tech\eng\cad_files\part_prints\" & varmoldnum & "\obsolete\"
end if
filename = "\\lexp-jasper\tech\eng\cad_files\part_prints\" & varmoldnum & "\" & filename & "pdf"
else
filename = "\\lexp-jasper\tech\eng\cad_files\part_prints\s_prints\" & filename & "pdf"
end if
varsheetname = strsheetname
if swexportpdfdata is nothing then msgbox "nothing"
boolstatus = swexportpdfdata.setsheets(swexportdata_exportspecifiedsheets, varsheetname)
boolstatus = swmodeldocext.saveas(filename, 0, 0, swexportpdfdata, longstatus, longwarnings)
boolstatus = swmodeldocext.saveas(filename2, 0, 0, swexportpdfdata, longstatus, longwarnings)
end sub
dell precision | m65
quadro fx350
2g ram
windows xp
sw2009 - wish i could go back to sw2008
retval = swexportdata.setsheets(swexportdata_exportcurrentsheet, 1)
answer thanks a lot khris, i'll try with this code.
quick
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-12-23 15:25 , Processed in 0.036579 second(s), 20 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

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