Message 1 of 11
Batchplot
Not applicable
06-23-2003
10:20 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all,
This code is the one I found in the Autocad 2002 VBAHelp. I tried to adapt
it to my needs but unsucsefully......
The original code passes through all layouts existing in the drawing and ask
if you want to plot it. Working perfectly.
What I am trying to do is filter out some specific layouts named for example
"A3 1-200*". I marked my modifications (very simple) in the code by some "
**** ".
When I do that in the code, only one of them gets plotted. Does anyone know
why???
Thanks in advance for your attention,
Gilles
Code begins
****************************************************
Sub SetLayoutsToPlot()
' This example creates a Circle in model space and allows the user
' to select which layouts for the drawing to plot. It then uses
' a batch operation to send the selected layouts to the current
' plot device and allows the user to cancel the batch plot at certain
' intervals.
Dim Plot As AcadPlot
Dim AddedLayouts() As String
Dim LayoutList As Variant
Dim Layout As AcadLayout
Dim ArraySize As Integer, BatchCount As Integer
' Prompt user for Layouts to plot
For Each Layout In ThisDrawing.Layouts
If Layout.Name Like "A3 1-200*" Then '**** **** **** ****
**** **** **** **** **** **** **** ****
If MsgBox("Do you wish to plot the layout: " & Layout.Name,
vbYesNo) = vbYes Then
ArraySize = ArraySize + 1
ReDim AddedLayouts(1 To ArraySize)
AddedLayouts(ArraySize) = Layout.Name
End If
'**** **** **** **** **** **** **** **** **** **** **** ****
End If
Next
' If the user did not select any Layouts to plot then exit
If ArraySize = 0 Then
MsgBox "There was no Layout selected"
Exit Sub
End If
' Send the array list containing the layout names to a variant
' which is compatible with SetLayoutsToPlot
LayoutList = AddedLayouts
' Get the plot object from the drawing
Set Plot = ThisDrawing.Plot
' Set plot options
Plot.QuietErrorMode = False ' We do want to be notified of errors
' * Note: Normally, in a batch
situation, you do
' not want to be notified of errors,
since this
' will halt the batch process.
Plot.NumberOfCopies = 1 ' We only need one copy
' Start the batch plot the selected layouts
Plot.StartBatchMode ArraySize ' Number of items in this batch
For BatchCount = 1 To ArraySize
' This must be called every time we call PlotToDevice
Plot.SetLayoutsToPlot LayoutList
' Plot to default device
Plot.PlotToDevice
' Display the results of the batch plot. This property should
really be
' displayed to and set from a VBA Form, but for this example, we
will
' use a message box
If Plot.BatchPlotProgress Then
If MsgBox("Would you like to cancel the batch plot?", vbYesNo) =
vbYes Then
Plot.BatchPlotProgress = False
End If
Else
MsgBox "The batch plot has finished!"
End If
Next
MsgBox "Finished plotting the selected Layouts!"
End Sub
****************************************************
Code ends
This code is the one I found in the Autocad 2002 VBAHelp. I tried to adapt
it to my needs but unsucsefully......
The original code passes through all layouts existing in the drawing and ask
if you want to plot it. Working perfectly.
What I am trying to do is filter out some specific layouts named for example
"A3 1-200*". I marked my modifications (very simple) in the code by some "
**** ".
When I do that in the code, only one of them gets plotted. Does anyone know
why???
Thanks in advance for your attention,
Gilles
Code begins
****************************************************
Sub SetLayoutsToPlot()
' This example creates a Circle in model space and allows the user
' to select which layouts for the drawing to plot. It then uses
' a batch operation to send the selected layouts to the current
' plot device and allows the user to cancel the batch plot at certain
' intervals.
Dim Plot As AcadPlot
Dim AddedLayouts() As String
Dim LayoutList As Variant
Dim Layout As AcadLayout
Dim ArraySize As Integer, BatchCount As Integer
' Prompt user for Layouts to plot
For Each Layout In ThisDrawing.Layouts
If Layout.Name Like "A3 1-200*" Then '**** **** **** ****
**** **** **** **** **** **** **** ****
If MsgBox("Do you wish to plot the layout: " & Layout.Name,
vbYesNo) = vbYes Then
ArraySize = ArraySize + 1
ReDim AddedLayouts(1 To ArraySize)
AddedLayouts(ArraySize) = Layout.Name
End If
'**** **** **** **** **** **** **** **** **** **** **** ****
End If
Next
' If the user did not select any Layouts to plot then exit
If ArraySize = 0 Then
MsgBox "There was no Layout selected"
Exit Sub
End If
' Send the array list containing the layout names to a variant
' which is compatible with SetLayoutsToPlot
LayoutList = AddedLayouts
' Get the plot object from the drawing
Set Plot = ThisDrawing.Plot
' Set plot options
Plot.QuietErrorMode = False ' We do want to be notified of errors
' * Note: Normally, in a batch
situation, you do
' not want to be notified of errors,
since this
' will halt the batch process.
Plot.NumberOfCopies = 1 ' We only need one copy
' Start the batch plot the selected layouts
Plot.StartBatchMode ArraySize ' Number of items in this batch
For BatchCount = 1 To ArraySize
' This must be called every time we call PlotToDevice
Plot.SetLayoutsToPlot LayoutList
' Plot to default device
Plot.PlotToDevice
' Display the results of the batch plot. This property should
really be
' displayed to and set from a VBA Form, but for this example, we
will
' use a message box
If Plot.BatchPlotProgress Then
If MsgBox("Would you like to cancel the batch plot?", vbYesNo) =
vbYes Then
Plot.BatchPlotProgress = False
End If
Else
MsgBox "The batch plot has finished!"
End If
Next
MsgBox "Finished plotting the selected Layouts!"
End Sub
****************************************************
Code ends