VBA Plotting Page Setups
CADForums.net Forum Index CADForums.net
Discussion of AutoCAD and other CAD software.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
VBA Plotting Page Setups
Post new topic   Reply to topic    CADForums.net Forum Index -> VBA

Author Message
Peterg
Guest





Posted: Tue Dec 07, 2004 3:43 am    Post subject: VBA Plotting Page Setups Reply with quote

Ok, here is what I am trying to do. Using AutoCAD Mech. 2005

User opens up a drawing, a listbox pops-up and lists all the Page Setups within that drawing. The user can then select which Page Setup he wants to Preview or Plot.

Everything I have read tells me to use the following code(Showed Print Preview code only):

Dim PlotConfigurations As AcadPlotConfigurations
Dim Plot As AcadPlot
Dim Activelayout As AcadLayout

Set PlotConfigurations = ThisDrawing.PlotConfigurations
Set Plot = ThisDrawing.Plot
Set Activelayout = ThisDrawing.Activelayout
Activelayout.CopyFrom PlotConfigurations.Item(lstName.Value) 'lstname.value is the user selected Page Setup

Activelayout.RefreshPlotDeviceInfo
ThisDrawing.Regen acAllViewports
Plot.DisplayPlotPreview acFullPreview


This code 'usually' works for the first Plot Preview that you do, or the first PlotToDevice. If I try and Preview or Plot the next user selected Page Setup, it defaults to 8-1/2 x 11, Landscape. Even if the Page Setup is a DSIZE paper, different Printer, ect. If I print it, it will go to the printer defined in the Page Setup, but the paper size and orientation will be wrong.

These Page Setups work fine when using the AutoCAD native PLOT window.

It is like the copyfrom command is not resetting all the variables.

Any help would be greatly appreciated. I have been banging my head for a week now trying different things.

Peter

Back to top
Jorge Lopez
Guest





Posted: Tue Dec 07, 2004 4:32 am    Post subject: Re: VBA Plotting Page Setups Reply with quote

Use different variable names from the default property names on ThisDrawing.
It is really confusing to see:

Set Activelayout = Activelayout
Activelayout.CopyFrom PlotConfigurations.Item(lstName.Value)
'lstname.value is the user selected Page Setup

I can't even tell from that if ThisDrawing.ActiveLayout or your ActiveLayout
variable is being used without running the code. In this case they are both
the same thing but ThisDrawing.ActiveLayout always returns the current
layout object in AutoCAD while your variable could be referring to a
different layout (if it changed after setting the variable).

I'm not entirely sure what you are trying to do but here is your code
modified to plot preview all the page setups:

Sub test()
Dim oPlotConfig As AcadPlotConfiguration
For Each oPlotConfig In ThisDrawing.PlotConfigurations
ThisDrawing.Activelayout.CopyFrom oPlotConfig

Activelayout.RefreshPlotDeviceInfo
ThisDrawing.Regen acAllViewports

ThisDrawing.Plot.DisplayPlotPreview acFullPreview
Next
End Sub

Hope this helps.

- Jorge


"Peterg" <nospam@address.withheld> wrote in message
news:16109497.1102373023785.JavaMail.jive@jiveforum2.autodesk.com...
Quote:
Ok, here is what I am trying to do. Using AutoCAD Mech. 2005

User opens up a drawing, a listbox pops-up and lists all the Page Setups
within that drawing. The user can then select which Page Setup he wants
to Preview or Plot.

Everything I have read tells me to use the following code(Showed Print
Preview code only):

Dim PlotConfigurations As AcadPlotConfigurations
Dim Plot As AcadPlot
Dim Activelayout As AcadLayout

Set PlotConfigurations = ThisDrawing.PlotConfigurations
Set Plot = ThisDrawing.Plot
Set Activelayout = ThisDrawing.Activelayout
Activelayout.CopyFrom PlotConfigurations.Item(lstName.Value)
'lstname.value is the user selected Page Setup

Activelayout.RefreshPlotDeviceInfo
ThisDrawing.Regen acAllViewports
Plot.DisplayPlotPreview acFullPreview


This code 'usually' works for the first Plot Preview that you do, or the
first PlotToDevice. If I try and Preview or Plot the next user selected
Page Setup, it defaults to 8-1/2 x 11, Landscape. Even if the Page Setup
is a DSIZE paper, different Printer, ect. If I print it, it will go to
the printer defined in the Page Setup, but the paper size and orientation
will be wrong.

These Page Setups work fine when using the AutoCAD native PLOT window.

It is like the copyfrom command is not resetting all the variables.

Any help would be greatly appreciated. I have been banging my head for a
week now trying different things.

Peter
Back to top
Peterg
Guest





Posted: Tue Dec 07, 2004 7:03 pm    Post subject: Re: VBA Plotting Page Setups Reply with quote

Hi Jorge, thx for the code cleanup, but I am still having the exact same problems using your code or mine.

This method works fine when you have similiar Page Setups, ie. Same paper size and orientation.

I have drawings with totally different Page setups, ie. different paper sizes, orientations, plotters, ect.

So, I step through your code on a sample drawing, the first 4 Page setups work great, but when it comes across a Page Setup that changes paper size I get "Method 'DisplayPlotPreview' of Object 'IAcadPlot' failed".

So, I tested it on a different drawing, again works fine while dealing with similiar Page setups until it get a Page Setup that switches plotter (different .pc3 file). It does not switch orientation and stays with the 8-1/2 x 11" paper size.

Some how the variables for paper size and orientaion are not being set correctly. They stay the same as the Activelayout that the drawing was opened with.

I hope that is not too confusing of an explanation.

I guess I could try an invoke the PLOT window and use it to plot off my Page setups, but I had a hard time with the Endcommand or Endplot. It would work ok if I was plotting off one Page setup, but tended to screw up if I plotted multiple Page Setups.

Peter
Back to top
Peterg
Guest





Posted: Tue Dec 07, 2004 8:38 pm    Post subject: Re: VBA Plotting Page Setups Reply with quote

FYI - I sent my code to a Autodesk tech. It works fine on his AutoCAD 2005 (non-Mech) setup.

So, he is trying to determine if this is an AcadM 2005 problem.

Will keep you posted.

Peter
Back to top
Peterg
Guest





Posted: Wed Dec 08, 2004 2:33 am    Post subject: Re: VBA Plotting Page Setups Reply with quote

Well, I am now back to square1.

The AutoDesk Tech said my code worked fine on his ACADM 2005.

The exact same code does not work fine on my ACADM 2005.

I am running Acad SP1.1 with Windows 2000. I even tried it on an XP machine here, same thing, does not work.

If anyone has created a Custom VBA Plotting program that will print off 'Page Setups' involving different printers, paper sizes, ect. Please reply to this message.

Peter
Back to top
James Belshan
Guest





Posted: Wed Dec 08, 2004 4:36 am    Post subject: Re: VBA Plotting Page Setups Reply with quote

Peter,
Here's the only workaround I found for similar problems....

What I found when changing the plot area in my code was that I had to open
and close the PageSetup dialog in order for the print area to change on
screen (and in the plot). I did a hack like:

Code:

    .CenterPlot = true   'the settings you're changing
    SendKeys "{ENTER}"
    ThisDrawing.SendCommand ("pagesetup" & vbCr)


Occasionally the ENTER key doesn't get sent to the dialog and the dialog is
left hanging open (if I hit a key between starting my code and when it gets
to this point), but my work is all in-house so it's no big deal. We just hit
ENTER to close the dialog box and the macro continues on.

One way to tell if this will help you is to stop your code just after you
make your changes, and then manually open and close the pagesetup dialog
box. If the print area adjusts itself, then this snippet will help you.

HTH,

James



"Peterg" <nospam@address.withheld> wrote in message
news:15250666.1102428222788.JavaMail.jive@jiveforum2.autodesk.com...
Quote:
Hi Jorge, thx for the code cleanup, but I am still having the exact same
problems using your code or mine.

This method works fine when you have similiar Page Setups, ie. Same paper
size and orientation.

I have drawings with totally different Page setups, ie. different paper
sizes, orientations, plotters, ect.

So, I step through your code on a sample drawing, the first 4 Page setups
work great, but when it comes across a Page Setup that changes paper size I

get "Method 'DisplayPlotPreview' of Object 'IAcadPlot' failed".
Quote:

So, I tested it on a different drawing, again works fine while dealing
with similiar Page setups until it get a Page Setup that switches plotter

(different .pc3 file). It does not switch orientation and stays with the
8-1/2 x 11" paper size.
Quote:

Some how the variables for paper size and orientaion are not being set
correctly. They stay the same as the Activelayout that the drawing was

opened with.
Quote:

I hope that is not too confusing of an explanation.

I guess I could try an invoke the PLOT window and use it to plot off my
Page setups, but I had a hard time with the Endcommand or Endplot. It would

work ok if I was plotting off one Page setup, but tended to screw up if I
plotted multiple Page Setups.
Quote:

Peter
Back to top
hwalker
Guest





Posted: Wed Dec 08, 2004 1:39 pm    Post subject: Re: VBA Plotting Page Setups Reply with quote

I've written a program that does exactly what you want BUT it only works in AutoCAD LT, its called Multiplot and you can find it at www.caddepot.com on page 4 of the AutoCAD LT sub directory. It uses dynamic data exchange so if you want me to see if I can change it to work on your system send me a screenshot with your program running to hswalker@hotmail.com, and I'll see what I can do.
Back to top
Peterg
Guest





Posted: Fri Dec 10, 2004 6:40 pm    Post subject: Re: VBA Plotting Page Setups Reply with quote

Update:

I have been dealing with an AutoDesk Reseller Tech, so far no luck with the bugs in the copyfrom cmd.

But, I have been able to use the built-in PLOT successfully as a work-around.

Thanks for all your help and suggestions. I will keep you up to date if I find any solution.

btw - I am using ACADM in the Inventor Series 9 suite.

Peter
Back to top
Peterg
Guest





Posted: Wed Feb 02, 2005 8:46 pm    Post subject: Re: VBA Plotting Page Setups Reply with quote

Update:

I still have not found a solution to the copyfrom bug. The Autodesk reseller confirmed and submitted the bug to Autodesk.

Has anyone else come across this problem? If so, please let me know if you have found a solution.

Thanks

Peter
Back to top
Kerbo1969
Guest





Posted: Fri Feb 04, 2005 12:12 am    Post subject: Re: VBA Plotting Page Setups Reply with quote

Peter,
I don't see any reason why your code wouldn't work. So I am throwing this out there simply as something else to try. I don't have Mechanical to try it myself. Note the only real difference is the ".Add" statement.

Dim objLayout As AcadLayout
Dim PlotConfig As AcadPlotConfiguration
Set PlotConfig = ThisDrawing.PlotConfigurations.Add(PSetup)

Set objLayout = ThisDrawing.ActiveLayout
objLayout.CopyFrom PlotConfig

Robert
Back to top
kristo



Joined: 24 Jan 2008
Posts: 1
Location: melbourne, australia

Posted: Thu Jan 24, 2008 3:09 am    Post subject: Re: VBA Plotting Page Setups Reply with quote

hwalker wrote:
I've written a program that does exactly what you want BUT it only works in AutoCAD LT, its called Multiplot and you can find it at www.caddepot.com on page 4 of the AutoCAD LT sub directory. It uses dynamic data exchange so if you want me to see if I can change it to work on your system send me a screenshot with your program running to hswalker@hotmail.com, and I'll see what I can do.


does your program still work with the newer versions of AutoCAD LT 2007/2008 ?

also, I wonder do you have anything similar for etransmitting a group of files from LT ? (our office is cross-grading from full 2006 to LT 2008 and we have to work around the lack of a SheetSetManager which simplifies printing and emailing entire drawing projects).

thanks,
Kris.
Back to top
View user's profile Send private message Yahoo Messenger
 
Post new topic   Reply to topic    CADForums.net Forum Index -> VBA All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Access Forum - Microsoft Office Forum - Electronics

Contact Us Powered by phpBB