Problem using PlotWindow with PlotToDevice - prints wrong

Problem using PlotWindow with PlotToDevice - prints wrong

Anonymous
Not applicable
602 Views
8 Replies
Message 1 of 9

Problem using PlotWindow with PlotToDevice - prints wrong

Anonymous
Not applicable
I am writing a batch plot utility in VBA for AutoCAD 14.01. It has to be
able to handle a couple of different titleblock sizes. Each titleblock size
already has a configuration set up in the Preferences menu with their
respective paper sizes, rotations, line weights, etc. I was thinking all I
would have to do is set the PlotWindow size and then send it through the
correct configuration with PlotToDevice, but apparently I was mistaken. I
have monitored all the values calculated for the two window corners for each
drawing and verified both corners are calculated perfectly. LLcorner is
initialized to the insertion point of the block and URcorner is derived from
LLcorner, the titleblock width and height and the titleblock scale. When
the drawings print, though, the area printed does not match the values
assigned in PlotWindow. I've gone through the code numerous times and have
exhausted all logical reasoning (which is probably my problem...I'm thinking
too logically). I've also tried placing a Sleep command before PlotToDevice
thinking maybe the code executed too fast for the PlotWindow values to be
set before plotting the drawing, but it had no noticeable effect. Any
suggestions or help would be very much appreciated. TIA.

Select Case TBSize
Case "Bsize"
LLcorner(0) = LLcorner(0) + 0.375 * insScale
URcorner(0) = LLcorner(0) + 16.1875 * insScale: URcorner(1) =
LLcorner(1) + 10.59375 * insScale: URcorner(2) = LLcorner(2)
ThisDrawing.Plot.PlotWindow LLcorner, URcorner
ThisDrawing.Plot.PlotToDevice "BSize"
Case "AsizeP"
URcorner(0) = LLcorner(0) + 10 * insScale: URcorner(1) = LLcorner(1)
+ 7.875 * insScale: URcorner(2) = LLcorner(2)
ThisDrawing.Plot.PlotWindow LLcorner, URcorner
ThisDrawing.Plot.PlotToDevice "85X11P"
Case "AsizeL"
URcorner(0) = LLcorner(0) + 7.875 * insScale: URcorner(1) =
LLcorner(1) + 10 * insScale: URcorner(2) = LLcorner(2)
ThisDrawing.Plot.PlotWindow LLcorner, URcorner
ThisDrawing.Plot.PlotToDevice "85X11L"
Case "Dsize"
URcorner(0) = LLcorner(0) + 21.6 * insScale: URcorner(1) =
LLcorner(1) + 32.4 * insScale: URcorner(2) = LLcorner(2)
ThisDrawing.Plot.PlotWindow LLcorner, URcorner
ThisDrawing.Plot.PlotToDevice "CheckD"
End Select

M.E.T.
0 Likes
603 Views
8 Replies
Replies (8)
Message 2 of 9

Anonymous
Not applicable
Hi,
Try adding the following two lines to your code just before setting the plot
window. 🙂

'Translate the coordinates to the Display Coordinate System
LLcorner = ThisDrawing.Utility.TranslateCoordinates(LLcorner, acWorld,
acDisplayDCS, False)
URcorner = ThisDrawing.Utility.TranslateCoordinates(URcorner, acWorld,
acDisplayDCS, False)

Hope this helps,

- Adam <><

--
Enum SystemInfo
Cad_Software = "AutoCAD 14.01"
VB_Product = "VBA / VB6"
Platform = "WinNT4 SP5"
End Enum
0 Likes
Message 3 of 9

Anonymous
Not applicable
"Adam Waller" wrote in message
news:[email protected]...
> 'Translate the coordinates to the Display Coordinate System
> LLcorner = ThisDrawing.Utility.TranslateCoordinates(LLcorner, acWorld,
> acDisplayDCS, False)
> URcorner = ThisDrawing.Utility.TranslateCoordinates(URcorner, acWorld,
> acDisplayDCS, False)

I thought this could be the solution when I read it, but it didn't work
either. It prints the same way with or without the suggested code addition.
0 Likes
Message 4 of 9

Anonymous
Not applicable
Aha! I just learned something... 🙂
When you plot to a device other than the current plotting device, you lose
your plot window, (and other plot settings??)
The solution is to set the current device before setting your plot options.
(like the plot window)
You can set the plot device with the following line of code:
ThisDrawing.SetVariable "PLOTID", "8x11_L"

- Adam <><

P.S.
I would probably still leave in the TranslateCordinates lines. They might
save you a headache later on. 🙂

"MTeague" wrote in message
news:[email protected]...
> "Adam Waller" wrote in message
> news:[email protected]...
> > 'Translate the coordinates to the Display Coordinate System
> > LLcorner = ThisDrawing.Utility.TranslateCoordinates(LLcorner, acWorld,
> > acDisplayDCS, False)
> > URcorner = ThisDrawing.Utility.TranslateCoordinates(URcorner, acWorld,
> > acDisplayDCS, False)
>
> I thought this could be the solution when I read it, but it didn't work
> either. It prints the same way with or without the suggested code
addition.
>
0 Likes
Message 5 of 9

Anonymous
Not applicable
> ThisDrawing.SetVariable "PLOTID", "8x11_L"

This works! Thanks!
0 Likes
Message 6 of 9

Anonymous
Not applicable
ThisDrawing.Plot.PlotToDevice ("85X11P")

Rene

MTeague schreef in berichtnieuws
[email protected]...
> I am writing a batch plot utility in VBA for AutoCAD 14.01. It has to be
> able to handle a couple of different titleblock sizes. Each titleblock
size
> already has a configuration set up in the Preferences menu with their
> respective paper sizes, rotations, line weights, etc. I was thinking all
I
> would have to do is set the PlotWindow size and then send it through the
> correct configuration with PlotToDevice, but apparently I was mistaken. I
> have monitored all the values calculated for the two window corners for
each
> drawing and verified both corners are calculated perfectly. LLcorner is
> initialized to the insertion point of the block and URcorner is derived
from
> LLcorner, the titleblock width and height and the titleblock scale. When
> the drawings print, though, the area printed does not match the values
> assigned in PlotWindow. I've gone through the code numerous times and
have
> exhausted all logical reasoning (which is probably my problem...I'm
thinking
> too logically). I've also tried placing a Sleep command before
PlotToDevice
> thinking maybe the code executed too fast for the PlotWindow values to be
> set before plotting the drawing, but it had no noticeable effect. Any
> suggestions or help would be very much appreciated. TIA.
>
> Select Case TBSize
> Case "Bsize"
> LLcorner(0) = LLcorner(0) + 0.375 * insScale
> URcorner(0) = LLcorner(0) + 16.1875 * insScale: URcorner(1) =
> LLcorner(1) + 10.59375 * insScale: URcorner(2) = LLcorner(2)
> ThisDrawing.Plot.PlotWindow LLcorner, URcorner
> ThisDrawing.Plot.PlotToDevice "BSize"
> Case "AsizeP"
> URcorner(0) = LLcorner(0) + 10 * insScale: URcorner(1) =
LLcorner(1)
> + 7.875 * insScale: URcorner(2) = LLcorner(2)
> ThisDrawing.Plot.PlotWindow LLcorner, URcorner
> ThisDrawing.Plot.PlotToDevice "85X11P"
> Case "AsizeL"
> URcorner(0) = LLcorner(0) + 7.875 * insScale: URcorner(1) =
> LLcorner(1) + 10 * insScale: URcorner(2) = LLcorner(2)
> ThisDrawing.Plot.PlotWindow LLcorner, URcorner
> ThisDrawing.Plot.PlotToDevice "85X11L"
> Case "Dsize"
> URcorner(0) = LLcorner(0) + 21.6 * insScale: URcorner(1) =
> LLcorner(1) + 32.4 * insScale: URcorner(2) = LLcorner(2)
> ThisDrawing.Plot.PlotWindow LLcorner, URcorner
> ThisDrawing.Plot.PlotToDevice "CheckD"
> End Select
>
> M.E.T.
>
0 Likes
Message 7 of 9

Anonymous
Not applicable
"Rene" wrote in message
news:[email protected]...
>
> ThisDrawing.Plot.PlotToDevice ("85X11P")

Placing parenthesis around the device name did not seem to make a
difference. I believe ThisDrawing.Plot.PlotToDevice ("85X11P") and
ThisDrawing.Plot.PlotToDevice "85X11P" achieve the same end. It is still
not printing the drawing area specified in the PlotWindow command (I am
getting prints, just not what I would expect given the coordinates). Thanks
for the quick reply, though!
0 Likes
Message 8 of 9

Anonymous
Not applicable
Try to make a regen after you've set the window and before you plot.

--
Best regards: Jimmy B
CAD coordinator at Emtunga International AB
http://hem.fyristorg.com/cadman/
www.emtunga.com
0 Likes
Message 9 of 9

Anonymous
Not applicable
"Jimmy B" wrote in message
news:[email protected]...
> Try to make a regen after you've set the window and before you plot.

Nope, still didn't work. If I erase the printer configurations from
Preferences and reload them from the PC2 files, the program works great --
the first time. Every time after that the prints come out wrong. Surely
there is a way to avoid reinstalling the PC2 files every time the program is
run?
0 Likes