• This forum is the machine-generated translation of www.cad3d.it/forum1 - the Italian design community. Several terms are not translated correctly.

print with vba

  • Thread starter Thread starter yag
  • Start date Start date

yag

Guest
salve devo stampare un dwg in pdf sto usando questo codice:

dim ptconfigs as acadplotconfigurations
dim plotconfig as acadplotconfiguration
dim ptobj as acadplot
dim backplot as variant

'create a new plot configutrarion with all needed parameters
set ptobj = thisdrawing.plot
set ptconfigs = thisdrawing.plotconfigurations
'add a new plot configuration
ptconfigs.add "pdf", false
'the plot config you created become active
set plotconfig = ptconfigs.item("pdf")
'use this method to set the scale
plotconfig.standardscale = acscaletofit
'updates the plot
plotconfig.refreshplotdeviceinfo
'here you specify the pc3 file you want to use
plotconfig.configname = "dwg to pdf.pc3"
'you can select the plot style table here
plotconfig.stylesheet = "acad.ctb"
'specifies whether or not to plot using the plot styles
plotconfig.plotwithplotstyles = true
'thisdrawing.layouts("model").canonicalmedianame = "a4"

'if you are going to create pdf files in a batch mode,
'i would recommend to turn off the backgroundplot system variable,
'so autocad will not continue to do anything until finishes
'the pdf creation
backplot = thisdrawing.getvariable("backgroundplot")
thisdrawing.setvariable "backgroundplot", 0
'updates the plot
plotconfig.refreshplotdeviceinfo
'now you can use the plottofile method
if ptobj.plottofile(replace(thisdrawing.fullname, "dwg", "pdf"), plotconfig.configname) then
msgbox "pdf was created"
else
msgbox "pdf creation unsuccessful"
end if
'if you wish you can delete th plot configuration you created
'programmatically, and set the 'backgroundplot' system variable
'to its original status.
ptconfigs.item("pdf").delete
set plotconfig = nothing
thisdrawing.setvariable "backgroundplot", backplot


però dovrei impostare il formato del foglio su a0 come fare ?
 
salve devo stampare un dwg in pdf sto usando questo codice:

dim ptconfigs as acadplotconfigurations
dim plotconfig as acadplotconfiguration
dim ptobj as acadplot
dim backplot as variant

'create a new plot configutrarion with all needed parameters
set ptobj = thisdrawing.plot
set ptconfigs = thisdrawing.plotconfigurations
'add a new plot configuration
ptconfigs.add "pdf", false
'the plot config you created become active
set plotconfig = ptconfigs.item("pdf")
'use this method to set the scale
plotconfig.standardscale = acscaletofit
'updates the plot
plotconfig.refreshplotdeviceinfo
'here you specify the pc3 file you want to use
plotconfig.configname = "dwg to pdf.pc3"
'you can select the plot style table here
plotconfig.stylesheet = "acad.ctb"
'specifies whether or not to plot using the plot styles
plotconfig.plotwithplotstyles = true
'thisdrawing.layouts("model").canonicalmedianame = "a4"

'if you are going to create pdf files in a batch mode,
'i would recommend to turn off the backgroundplot system variable,
'so autocad will not continue to do anything until finishes
'the pdf creation
backplot = thisdrawing.getvariable("backgroundplot")
thisdrawing.setvariable "backgroundplot", 0
'updates the plot
plotconfig.refreshplotdeviceinfo
'now you can use the plottofile method
if ptobj.plottofile(replace(thisdrawing.fullname, "dwg", "pdf"), plotconfig.configname) then
msgbox "pdf was created"
else
msgbox "pdf creation unsuccessful"
end if
'if you wish you can delete th plot configuration you created
'programmatically, and set the 'backgroundplot' system variable
'to its original status.
ptconfigs.item("pdf").delete
set plotconfig = nothing
thisdrawing.setvariable "backgroundplot", backplot


però dovrei impostare il formato del foglio su a0 come fare ?
No hand?
 
thisdrawing.layouts("model").canonicalmedianame = "iso_full_bleed_a0_(841.00_x_1189.00_mm)"

check what from thisdrawing.layouts("model").canonicalmedianame by manually setting on a0 and use that !!!
 
thisdrawing.layouts("model").canonicalmedianame = "iso_full_bleed_a0_(841.00_x_1189.00_mm)"

check what from thisdrawing.layouts("model").canonicalmedianame by manually setting on a0 and use that !!!
already done but by mistake if imposed the canonical and is not present
 
already done but by mistake if imposed the canonical and is not present
or better so recover that of the current version but the soft I will make it line on different machines and versions perhaps it would be better to recover the runtime list of the paper size and make it select to the user. . .
 
or create runtime a paper size equal to a0 (how to recover these settings? ) and then I imposed it...
 
or create runtime a paper size equal to a0 (how to recover these settings? ) and then I imposed it...
bhè if you have to use a format imposed by a print driver and the driver is not always the same with the same settings I see it hard to define one that goes well for everyone.. .

I don't know. and distribute a pmp file (customized child installments) to be uploaded to pdf.pc3 can be an idea?
 
bhè if you have to use a format imposed by a print driver and the driver is not always the same with the same settings I see it hard to define one that goes well for everyone.. .

I don't know. and distribute a pmp file (customized child installments) to be uploaded to pdf.pc3 can be an idea?
can I create a setting and then load it runtime?
 
I found the way to recover the list of canonicalnames but when imposed
this iso_expand_a0_(841.00_x_1189.00_mm) misrepresents me recovery by code and is present between the list if I do it by hand instead it works
 
ok I solved does the print but I do not understand why it remains very small in comparison to pdf
 
So after the press, there's no way to rotate it, is there?
rotate pdf?

I would say by autocad just no.....
If you have to rotate it see if you can already from the print settings to define horizontal or vertical?
 
already done but by mistake if imposed the canonical and is not present
then we say that this code:


dim ptconfigs as acadplotconfigurations
dim plotconfig as acadplotconfiguration
dim ptobj as acadplot
dim backplot as variant

'create a new plot configutrarion with all needed parameters
set ptobj = thisdrawing.plot
set ptconfigs = thisdrawing.plotconfigurations

ptconfigs.add "pdf", false
set plotconfig = ptconfigs.item("pdf)
plotconfig.refreshplotdeviceinfo

plotconfig.configname = "dwg to pdf.pc3"
'plotconfig.canomedianame = 'ansi_a_(11.00_x_8.50_inches)'
'plotconfig.standardscale = acscaletofit
'plotconfig.usestandardscale = true
'plotconfig.setcustomscale 1, 1
'plotconfig.plottype = acextents
plotconfig.plotwithplotstyles = true
plotconfig.stylesheet = "acad.ctb"



newfilename = replace(lcase(thisdrawing.fullname), "dwg", "pdf")
newfilename = ucase(newfilename)


if ptobj.plottofile(newfilename, plotconfig.configname) then

msgbox "uncreated pdf error"
end if

ptconfigs.item("pdf").
set plotconfig = nothing


creates me "good" the pdf but badly rotated when I open it with autocad
to put it straight I always have to rotate it with acrobad of 90 degrees anticlockwise

but the problem is still not the problem and that the black and white print not in color as ever?
 
but the problem is still not the problem and that the black and white print not in color as ever?
from what I read, plotconfig.stylesheet = "acad.ctb" sets the style for the layout not for the model space... Maybe it's that!!!

in fact if manually imposed the print style acad.ctb and then throw the macro the pdf comes out in color
 
from what I read, plotconfig.stylesheet = "acad.ctb" sets the style for the layout not for the model space... Maybe it's that!!!

in fact if manually imposed the print style acad.ctb and then throw the macro the pdf comes out in color
I was entering the forum to write this but how do I solve it?
 
I was entering the forum to write this but how do I solve it?
if it can be useful the additional code for rotation provided that you have installed acrobad writer is this:

dim acroapp as acrobat.cacroapp
dim part1document as acrobat.cacropddoc
dim numpages as integer
dim page as cacropdpage

set acroapp = createobject("acroexch.app")
set part1document = createobject("acroexch.pddoc")
part1document.open (newfilename)
set page = part1document.acquirepage(0)
'acroapp.show
page.setrotate (pdrotate270)
part1document.save 1, newfilename
part1document.close
acroapp.exit
 
if it can be useful the additional code for rotation provided that you have installed acrobad writer is this:

dim acroapp as acrobat.cacroapp
dim part1document as acrobat.cacropddoc
dim numpages as integer
dim page as cacropdpage

set acroapp = createobject("acroexch.app")
set part1document = createobject("acroexch.pddoc")
part1document.open (newfilename)
set page = part1document.acquirepage(0)
'acroapp.show
page.setrotate (pdrotate270)
part1document.save 1, newfilename
part1document.close
acroapp.exit

ho risolto così


thisdrawing.activelayout.plotwithplotstyles = false
thisdrawing.activelayout.plotwithlineweights = false
 

Forum statistics

Threads
44,997
Messages
339,767
Members
4
Latest member
ibt

Members online

No members online now.
Back
Top