Message 1 of 10
VBA Plotting Page Setups

Not applicable
12-06-2004
02:43 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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
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