Batchplot

Batchplot

Anonymous
Not applicable
1,192 Views
10 Replies
Message 1 of 11

Batchplot

Anonymous
Not applicable
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
0 Likes
1,193 Views
10 Replies
Replies (10)
Message 2 of 11

Anonymous
Not applicable
try....
ReDim Preserve AddedLayouts(1 To ArraySize)
hth
Mark

"Gilles" wrote in message
news:[email protected]...
> 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
>
>
0 Likes
Message 3 of 11

Anonymous
Not applicable
Thanks Mark,


Working nearby perfectly. Now I get all my layouts plotted BUT 2
times........ 🙂
Once not enough, once too much.....
You know what is happening?


Gilles



"Mark Propst" a écrit dans le message de
news:[email protected]...
> try....
> ReDim Preserve AddedLayouts(1 To ArraySize)
> hth
> Mark
>
> "Gilles" wrote in message
> news:[email protected]...
> > 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
> >
> >
>
>
0 Likes
Message 4 of 11

Anonymous
Not applicable
After a few tries, I have not isolated the problem but

If I have 2 layouts, they are printed 2 times, so 2x2
If I have 3 layouts, they are printed 3 times, so 3x3
If I have 4 layouts, they are printed 4 times, so 4x4
.....

So much paper.....


Gilles



"Gilles" a écrit dans le message de
news:[email protected]...
> Thanks Mark,
>
>
> Working nearby perfectly. Now I get all my layouts plotted BUT 2
> times........ 🙂
> Once not enough, once too much.....
> You know what is happening?
>
>
> Gilles
>
>
>
> "Mark Propst" a écrit dans le message de
> news:[email protected]...
> > try....
> > ReDim Preserve AddedLayouts(1 To ArraySize)
> > hth
> > Mark
> >
> > "Gilles" wrote in message
> > news:[email protected]...
> > > 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
> > >
> > >
> >
> >
>
>
0 Likes
Message 5 of 11

Anonymous
Not applicable
For BatchCount = 1 To ArraySize
> > > ' This must be called every time we call PlotToDevice
> > > Plot.SetLayoutsToPlot LayoutList
> > >
you're printing once for each layout in your list?
:-)

"Gilles" wrote in message
news:[email protected]...
> After a few tries, I have not isolated the problem but
>
> If I have 2 layouts, they are printed 2 times, so 2x2
> If I have 3 layouts, they are printed 3 times, so 3x3
> If I have 4 layouts, they are printed 4 times, so 4x4
> .....
>
> So much paper.....
>
>
> Gilles
>
>
>
> "Gilles" a écrit dans le message de
> news:[email protected]...
> > Thanks Mark,
> >
> >
> > Working nearby perfectly. Now I get all my layouts plotted BUT 2
> > times........ 🙂
> > Once not enough, once too much.....
> > You know what is happening?
> >
> >
> > Gilles
> >
> >
> >
> > "Mark Propst" a écrit dans le message de
> > news:[email protected]...
> > > try....
> > > ReDim Preserve AddedLayouts(1 To ArraySize)
> > > hth
> > > Mark
> > >
> > > "Gilles" wrote in message
> > > news:[email protected]...
> > > > 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
> > > >
> > > >
> > >
> > >
> >
> >
>
>
0 Likes
Message 6 of 11

Anonymous
Not applicable
Mark,

That's what I am trying to do...
Have only one plot for each selected layout !

And now, it works fine... Thanks a lot

I deleted the "For BatchCount = 1 To ArraySize"

Don't understand why it was coded like this in the help...

(It was very bad for the paper roll...) 😉


Gilles


"Mark Propst" a écrit dans le message de
news:[email protected]...
> For BatchCount = 1 To ArraySize
> > > > ' This must be called every time we call PlotToDevice
> > > > Plot.SetLayoutsToPlot LayoutList
> > > >
> you're printing once for each layout in your list?
> 🙂
>
> "Gilles" wrote in message
> news:[email protected]...
> > After a few tries, I have not isolated the problem but
> >
> > If I have 2 layouts, they are printed 2 times, so 2x2
> > If I have 3 layouts, they are printed 3 times, so 3x3
> > If I have 4 layouts, they are printed 4 times, so 4x4
> > .....
> >
> > So much paper.....
> >
> >
> > Gilles
> >
> >
> >
> > "Gilles" a écrit dans le message de
> > news:[email protected]...
> > > Thanks Mark,
> > >
> > >
> > > Working nearby perfectly. Now I get all my layouts plotted BUT 2
> > > times........ 🙂
> > > Once not enough, once too much.....
> > > You know what is happening?
> > >
> > >
> > > Gilles
> > >
> > >
> > >
> > > "Mark Propst" a écrit dans le message de
> > > news:[email protected]...
> > > > try....
> > > > ReDim Preserve AddedLayouts(1 To ArraySize)
> > > > hth
> > > > Mark
> > > >
> > > > "Gilles" wrote in message
> > > > news:[email protected]...
> > > > > 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
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
0 Likes
Message 7 of 11

Anonymous
Not applicable
Yeah, the help files can be very useful to get the idea of how things are
done, but you have to really study each line to see if it's what you want in
your application.
Unfortunately there's also lots of stuff that's just plain wrong and when
you're trying to learn (like me) it's really tough to figure out which is
which.
Thank goodness for this ng!

"Gilles" wrote in message
news:[email protected]...
> Mark,
>
> That's what I am trying to do...
> Have only one plot for each selected layout !
>
> And now, it works fine... Thanks a lot
>
> I deleted the "For BatchCount = 1 To ArraySize"
>
> Don't understand why it was coded like this in the help...
>
> (It was very bad for the paper roll...) 😉
>
>
> Gilles
>
>
> "Mark Propst" a écrit dans le message de
> news:[email protected]...
> > For BatchCount = 1 To ArraySize
> > > > > ' This must be called every time we call PlotToDevice
> > > > > Plot.SetLayoutsToPlot LayoutList
> > > > >
> > you're printing once for each layout in your list?
> > 🙂
> >
> > "Gilles" wrote in message
> > news:[email protected]...
> > > After a few tries, I have not isolated the problem but
> > >
> > > If I have 2 layouts, they are printed 2 times, so 2x2
> > > If I have 3 layouts, they are printed 3 times, so 3x3
> > > If I have 4 layouts, they are printed 4 times, so 4x4
> > > .....
> > >
> > > So much paper.....
> > >
> > >
> > > Gilles
> > >
> > >
> > >
> > > "Gilles" a écrit dans le message de
> > > news:[email protected]...
> > > > Thanks Mark,
> > > >
> > > >
> > > > Working nearby perfectly. Now I get all my layouts plotted BUT 2
> > > > times........ 🙂
> > > > Once not enough, once too much.....
> > > > You know what is happening?
> > > >
> > > >
> > > > Gilles
> > > >
> > > >
> > > >
> > > > "Mark Propst" a écrit dans le message de
> > > > news:[email protected]...
> > > > > try....
> > > > > ReDim Preserve AddedLayouts(1 To ArraySize)
> > > > > hth
> > > > > Mark
> > > > >
> > > > > "Gilles" wrote in message
> > > > > news:[email protected]...
> > > > > > 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
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
0 Likes
Message 8 of 11

Anonymous
Not applicable
> Unfortunately there's also lots of stuff that's just plain wrong ...

Yeah, it's pretty obvious that the examples don't all get tested, since the
msgbox in this one didn't even have the intended buttons. Of course, it's
great that they are available for almost every command in the help file, and
I've used them a lot.

But to make them even better, Autodesk should run a beta-tester/editor
program for the next help file, and farm out the various subroutines to
different people to debug. After you get your name immortalized in online
help credits... why, you can die a happy wo/man


Here's the corrected example for SetLayoutsToPlot, free for Adesk's taking.

Sub Example_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 'jlb
Dim circleObj As AcadCircle
Dim centerPoint(0 To 2) As Double
Dim radius As Double
Dim Layout As AcadLayout
Dim ArraySize As Integer, BatchCount As Integer

' Define the Circle object
centerPoint(0) = 0: centerPoint(1) = 0: centerPoint(2) = 0
radius = 5#

' Create the Circle object in model space
Set circleObj = ThisDrawing.ModelSpace.AddCircle(centerPoint, radius)

ThisDrawing.Application.ZoomAll

' Prompt user for Layouts to plot
For Each Layout In ThisDrawing.Layouts
If MsgBox("Do you wish to plot the layout: " & Layout.Name, vbYesNo
+ vbQuestion) = vbYes Then 'flag "&" was incorrect - jlb
ArraySize = ArraySize + 1
ReDim Preserve AddedLayouts(1 To ArraySize)
AddedLayouts(ArraySize) = Layout.Name
End If
Next

' If the user did not select any Layouts to plot then exit
If ArraySize = 0 Then Exit Sub

' Send the array list containing the layout names to a variant 'delete
line - jlb
' which is compatible with SetLayoutsToPlot 'delete line - jlb
'LayoutList = AddedLayouts 'delete line - jlb

' 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

' SetLayoutsToPlot requires variant array, and for batch purposes
'jlb
' we want each layout to be in its own array 'jlb
Dim LayoutListItem(0 To 0) As String 'jlb
LayoutListItem(0) = AddedLayouts(BatchCount) 'jlb

' The single-cell array does not need to be copied into a variant,
but may if you want to... --- jlb
Dim varLayoutListItem As Variant 'jlb
varLayoutListItem = LayoutListItem 'jlb

' ...because the code runs with either of the following lines
uncommented --- jlb
Plot.SetLayoutsToPlot LayoutListItem 'jlb
'Plot.SetLayoutsToPlot varLayoutListItem 'jlb

' 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 +
vbQuestion) = vbYes Then 'flag "&" was incorrect - jlb
Plot.BatchPlotProgress = False
End If
Else
MsgBox "The batch plot has stopped!"
End If
Next

MsgBox "Finished plotting the selected Layouts!"
End Sub
0 Likes
Message 9 of 11

Anonymous
Not applicable
"James Belshan" wrote in message
news:[email protected]...
> > Unfortunately there's also lots of stuff that's just plain wrong ...
>
>
> Here's the corrected example for SetLayoutsToPlot, free for Adesk's
taking.
>

Nice work, James,
now can you fix the rest of them?
:-)
0 Likes
Message 10 of 11

Anonymous
Not applicable
"Mark Propst" asked:
> now can you fix the rest of them?


nahhhh... you don't need them, you're beyond them. You answer a lot of
questions here. So if they ever did this, I'd expect to see your name on a
couple of examples...

and, yes, I realize that donating time to a profit-making corporation
doesn't make much sense, but it's not the dumbest thing I've ever done.


James
0 Likes
Message 11 of 11

Anonymous
Not applicable
Thanks all for your attention

Gilles

"James Belshan" a écrit dans le message de
news:[email protected]...
>
> "Mark Propst" asked:
> > now can you fix the rest of them?
>
>
> nahhhh... you don't need them, you're beyond them. You answer a lot of
> questions here. So if they ever did this, I'd expect to see your name on
a
> couple of examples...
>
> and, yes, I realize that donating time to a profit-making corporation
> doesn't make much sense, but it's not the dumbest thing I've ever done.
>
>
> James
>
>
>
0 Likes