Paper size for plotting question

Paper size for plotting question

Anonymous
Not applicable
667 Views
10 Replies
Message 1 of 11

Paper size for plotting question

Anonymous
Not applicable
How do I indicate a specific paper size in VBA for a layout to be plotted?
I know that MediaName = ThisDrawing.ActiveLayout.CanonicalMediaName will
show the current papersize, but I can't seem to be able to set it to the
size I want. Any ideas or sample code would be great as this is keeping me
from completing an job.

thanks!
0 Likes
668 Views
10 Replies
Replies (10)
Message 2 of 11

Anonymous
Not applicable
Hi Monica,
You have the correct property, but for the change to take effect you MUS use
the Regen method of the Active Document (VBA = ThisDrawing).
A simple example? Sure thing:

Public Sub Set2Legal()
Dim objLO As AcadLayout
Set objLO = ThisDrawing.ActiveLayout
objLO.CanonicalMediaName = "Legal"
'are you missing this line?
ThisDrawing.Regen acActiveViewport
End Sub

Randall Rath
0 Likes
Message 3 of 11

Anonymous
Not applicable
Hello monica and randall.

.CanonicalMediaName = "Your Papersize"
.RefreshPlotDeviceInfo

Has this the same effect to you as forcing a regen? I use this in my custom
plot program and it never gives problems.

Greetings,
--
Henk

CadFancy - Adventures in Visual Basic
www.CadFancy.myweb.nl
0 Likes
Message 4 of 11

Anonymous
Not applicable
Hi Henk,
It depends on your needs! By using the regen you see the change in the
drawing. The Refresh plot device info applies the change, but does not
change the layout on the screen.
So, they are different. Does that mean you should change? Not if what you
have works for you!

Randall Rath
0 Likes
Message 5 of 11

Anonymous
Not applicable
Ah, I think I understand now, I even discovered I had a problem there too.
When my program created a new layout with it's custom plotsettings and the
scale was set to acScaleToFit, the final visual result was poor: The black
background didn't fit with the paperboundary. Even with a manual regen
nothing changed, although the result of my plotexample sub was good. Only
with opening the PageSetup dialog directly followed with Ok the background
fits.

I found a weird solution to this: after programmatically regenerating the
drawing, and before a ZoomAll I cal the .StandardScale property for the
second time like this:

If Thisdrawing.ActiveLayout.StandardScale = acScaleToFit Then
ActiveLayout.StandardScale = acScaleToFit
End If

A strange solution, but it works

Greetings,
--
Henk

CadFancy - Adventures in Visual Basic
www.CadFancy.myweb.nl
0 Likes
Message 6 of 11

Anonymous
Not applicable
Actually, I'm having a different problem. I want to set the new papersize
to plot in the statement:
ThisDrawing.Layouts("Mysheet").CanonicalMediaName = "(22.00 x 34.00)"

I keep getting errors though. Any ideas?

"Henk Loonstra" wrote in message
news:D24B87C5DC8D2D110E8F1650B65180EF@in.WebX.maYIadrTaRb...
> Ah, I think I understand now, I even discovered I had a problem there too.
> When my program created a new layout with it's custom plotsettings and the
> scale was set to acScaleToFit, the final visual result was poor: The black
> background didn't fit with the paperboundary. Even with a manual regen
> nothing changed, although the result of my plotexample sub was good. Only
> with opening the PageSetup dialog directly followed with Ok the background
> fits.
>
> I found a weird solution to this: after programmatically regenerating the
> drawing, and before a ZoomAll I cal the .StandardScale property for the
> second time like this:
>
> If Thisdrawing.ActiveLayout.StandardScale = acScaleToFit Then
> ActiveLayout.StandardScale = acScaleToFit
> End If
>
> A strange solution, but it works
>
> Greetings,
> --
> Henk
>
> CadFancy - Adventures in Visual Basic
> www.CadFancy.myweb.nl
>
0 Likes
Message 7 of 11

Anonymous
Not applicable
Are you sure the name "(22.00 x 34.00)" is the right name for your
papersize?
Maybe you should check it with:
1. Setting the papersize active with the Plot dialog
2. Debug.Print Thisdrawing.ActiveLayout.CanonicalMediaName

By the way, what errormessages do you get?

Greetings,
--
Henk

CadFancy - Adventures in Visual Basic
www.CadFancy.myweb.nl

Monica Eisfeld schreef in berichtnieuws
3A4D77AA5DDB3748BC1C51AFBF1EA430@in.WebX.maYIadrTaRb...
> Actually, I'm having a different problem. I want to set the new papersize
> to plot in the statement:
> ThisDrawing.Layouts("Mysheet").CanonicalMediaName = "(22.00 x 34.00)"
>
> I keep getting errors though. Any ideas?
0 Likes
Message 8 of 11

Anonymous
Not applicable
The error message I get is "invalid input". If I use the statement
strMedia=ThisDrawing.ActiveLayout.CanonicalMediaName I get "11x17". Yet if
I use ThisDrawing.Layouts("MyLayout").CanonicalMediaName = "11x17" I get the
error. This seems really strange since it's the exact same string!! I'm at
a total loss here.

"Henk Loonstra" wrote in message
news:B02188DEF817DBC5E48B1DD53AA17C99@in.WebX.maYIadrTaRb...
> Are you sure the name "(22.00 x 34.00)" is the right name for your
> papersize?
> Maybe you should check it with:
> 1. Setting the papersize active with the Plot dialog
> 2. Debug.Print Thisdrawing.ActiveLayout.CanonicalMediaName
>
> By the way, what errormessages do you get?
>
> Greetings,
> --
> Henk
>
> CadFancy - Adventures in Visual Basic
> www.CadFancy.myweb.nl
>
> Monica Eisfeld schreef in berichtnieuws
> 3A4D77AA5DDB3748BC1C51AFBF1EA430@in.WebX.maYIadrTaRb...
> > Actually, I'm having a different problem. I want to set the new
papersize
> > to plot in the statement:
> > ThisDrawing.Layouts("Mysheet").CanonicalMediaName = "(22.00 x 34.00)"
> >
> > I keep getting errors though. Any ideas?
>
0 Likes
Message 9 of 11

Anonymous
Not applicable
Monica I just wrote a new thread stating the exact problem you describe. I
cant assign .CanonicalMediaName or .ConfigName without getting "invalid
input"

My code looks like:

Set Layout = myFile.PaperSpace.Layout
With Layout
.SetWindowToPlot wmPoint1, wmPoint2
.PlotType = acWindow
.ConfigName = plotDevice
.CanonicalMediaName = plotPaper
.SetCustomScale 1, wmPlotScale
.CenterPlot = True
End With


"Monica Eisfeld" skrev i meddelandet
news:82F7DE63C29D9F2D3FD05B3617D9AF37@in.WebX.maYIadrTaRb...
> The error message I get is "invalid input". If I use the statement
> strMedia=ThisDrawing.ActiveLayout.CanonicalMediaName I get "11x17". Yet
if
> I use ThisDrawing.Layouts("MyLayout").CanonicalMediaName = "11x17" I get
the
> error. This seems really strange since it's the exact same string!! I'm
at
> a total loss here.
>
> "Henk Loonstra" wrote in message
> news:B02188DEF817DBC5E48B1DD53AA17C99@in.WebX.maYIadrTaRb...
> > Are you sure the name "(22.00 x 34.00)" is the right name for your
> > papersize?
> > Maybe you should check it with:
> > 1. Setting the papersize active with the Plot dialog
> > 2. Debug.Print Thisdrawing.ActiveLayout.CanonicalMediaName
> >
> > By the way, what errormessages do you get?
> >
> > Greetings,
> > --
> > Henk
> >
> > CadFancy - Adventures in Visual Basic
> > www.CadFancy.myweb.nl
> >
> > Monica Eisfeld schreef in berichtnieuws
> > 3A4D77AA5DDB3748BC1C51AFBF1EA430@in.WebX.maYIadrTaRb...
> > > Actually, I'm having a different problem. I want to set the new
> papersize
> > > to plot in the statement:
> > > ThisDrawing.Layouts("Mysheet").CanonicalMediaName = "(22.00 x
34.00)"
> > >
> > > I keep getting errors though. Any ideas?
> >
>
0 Likes
Message 10 of 11

Anonymous
Not applicable
Monica,

I've worked around the problem!
If I call the .GetCanonicalMediaName and .GetPlotDeviceNames before trying
to assign .CanonicalMediaName and .ConfigName everything works perfectly!

Wonder why though? ;^)

Mats
--
"Nothing's impossible. It just takes a little longer"
======================================
mailto:mats.johansson@pqr.se
Mats Johansson
PQR Consult AB, Sweden

"Monica Eisfeld" skrev i meddelandet
news:82F7DE63C29D9F2D3FD05B3617D9AF37@in.WebX.maYIadrTaRb...
> The error message I get is "invalid input". If I use the statement
> strMedia=ThisDrawing.ActiveLayout.CanonicalMediaName I get "11x17". Yet
if
> I use ThisDrawing.Layouts("MyLayout").CanonicalMediaName = "11x17" I get
the
> error. This seems really strange since it's the exact same string!! I'm
at
> a total loss here.
>
> "Henk Loonstra" wrote in message
> news:B02188DEF817DBC5E48B1DD53AA17C99@in.WebX.maYIadrTaRb...
> > Are you sure the name "(22.00 x 34.00)" is the right name for your
> > papersize?
> > Maybe you should check it with:
> > 1. Setting the papersize active with the Plot dialog
> > 2. Debug.Print Thisdrawing.ActiveLayout.CanonicalMediaName
> >
> > By the way, what errormessages do you get?
> >
> > Greetings,
> > --
> > Henk
> >
> > CadFancy - Adventures in Visual Basic
> > www.CadFancy.myweb.nl
> >
> > Monica Eisfeld schreef in berichtnieuws
> > 3A4D77AA5DDB3748BC1C51AFBF1EA430@in.WebX.maYIadrTaRb...
> > > Actually, I'm having a different problem. I want to set the new
> papersize
> > > to plot in the statement:
> > > ThisDrawing.Layouts("Mysheet").CanonicalMediaName = "(22.00 x
34.00)"
> > >
> > > I keep getting errors though. Any ideas?
> >
>
0 Likes
Message 11 of 11

Anonymous
Not applicable
Hi Johansson, Mats
what is the data type of wmPoint1, wmPoint2 in your code.?
0 Likes