array trouble - Argument not Optional

array trouble - Argument not Optional

Anonymous
Not applicable
641 Views
19 Replies
Message 1 of 20

array trouble - Argument not Optional

Anonymous
Not applicable
I get an 'Argument not optional' error with the following code:

Dim arrCase(0 To 3) As AcadPlotConfigurations

Private Sub cmdGo_Click()
''Retrieve standard PlotConfigurations
''arrCase is an array of PlotConfigurations Collections
'' arrCase(0) => Cross Section sheets
'' arrCase(1) => 1:1 scale
'' arrCase(2) => 1:20 scale
'' arrCase(3) => 1:50 scale
Dim objDbxDoc As Object 'AxDbDocument
Set objDbxDoc =
AcadApplication.GetInterfaceObject("ObjectDBX.AxDbDocument")
objDbxDoc.Open "j:/1049/cad/submit/blocks/xspsetups.dwg"
arrCase(0) = objDbxDoc.CopyObjects(objDbxDoc.PlotConfigurations)
objDbxDoc.Open "j:/1049/cad/submit/blocks/1psetups.dwg"
arrCase(1) = objDbxDoc.CopyObjects(objDbxDoc.PlotConfigurations)
objDbxDoc.Open "j:/1049/cad/submit/blocks/20psetups.dwg"
arrCase(2) = objDbxDoc.CopyObjects(objDbxDoc.PlotConfigurations)
objDbxDoc.Open "j:/1049/cad/submit/blocks/50psetups.dwg"
arrCase(3) = objDbxDoc.CopyObjects(objDbxDoc.PlotConfigurations)
Set objDbxDoc = Nothing
''rest of sub clipped
End Sub

The error occurs at the first attempt to set the array element to a
PlotConfigurations object. That is, the line "arrCase(0) =
objDbxDoc.CopyObjects(...)".

I can't figure out which argument is missing?

TIA
Adam Wuellner
Civiltech Engineering, Inc.
0 Likes
642 Views
19 Replies
Replies (19)
Message 2 of 20

Anonymous
Not applicable
Try preceeding the arrCase() with a Set statement.

Joe
--
0 Likes
Message 3 of 20

Anonymous
Not applicable
Now I'm getting 'Invalid object array'

Set arrCase(0) = objDbxDoc.CopyObjects(objDbxDoc.PlotConfigurations)

"joesu" wrote in message
news:f0ffe98.0@WebX.maYIadrTaRb...
> Try preceeding the arrCase() with a Set statement.
> Joe
> --
>
>
0 Likes
Message 4 of 20

Anonymous
Not applicable
The first argument to CopyObjects() must be an array
of objects, not a collection.

You should use a function like this to get all of the
elements in the collection into an Array:

Public Function CollToVariant(Collection As Object) As Variant
Dim Result() As Object
ReDim Result(Collection.Count - 1)
Dim i As Long
For i = 0 To Collection.Count - 1
Set Result(i) = Collection.Item(i)
Next i
CollToVariant = Result
End Function

Then use

objDbxDoc.CopyObjects(CollToVariant(objDbxDoc.PlotConfigurations), ...)

You also need to assign the result of CopyObjects() to a
Variable, and test to see if it's an array and has at
least one element, before you try to reference elements
in it.


"Adam Wuellner" wrote in message
news:1410C743EE82BD159C3898393865A712@in.WebX.maYIadrTaRb...
> Now I'm getting 'Invalid object array'
>
> Set arrCase(0) = objDbxDoc.CopyObjects(objDbxDoc.PlotConfigurations)
>
> "joesu" wrote in message
> news:f0ffe98.0@WebX.maYIadrTaRb...
> > Try preceeding the arrCase() with a Set statement.
> > Joe
> > --
> >
> >
>
>
0 Likes
Message 5 of 20

Anonymous
Not applicable
Adam,

Change your code to this

objDbxDoc.Open "j:/1049/cad/submit/blocks/xspsetups.dwg"
Set arrCase(0) = objDbxDoc.PlotConfigurations

Joe
--
0 Likes
Message 6 of 20

Anonymous
Not applicable
"joesu" wrote in message
news:f0ffe98.3@WebX.maYIadrTaRb...
> Adam,
> Change your code to this
>
> objDbxDoc.Open "j:/1049/cad/submit/blocks/xspsetups.dwg"
> Set arrCase(0) = objDbxDoc.PlotConfigurations
>

What does this have to do with the result
of CopyObjects() ?????
0 Likes
Message 7 of 20

Anonymous
Not applicable
Not a thing, CopyObjects is not needed for what he is trying to accomplish.

Joe
--
0 Likes
Message 8 of 20

Anonymous
Not applicable
I'm trying to create an array of possible PlotConfigurations, from which
another sub will extract the appropriate collection and copy it into a
drawing.

I just read this from your book:
"Once again, this collection inherits a Delete method, which cannot be used.
To remove a plot configuration, use the Delete method of the
AcadPlotConfiguration object."(p 484)

I guess I won't be able to just wholesale swap the collection, which is why
I was trying it this way. I think I understand Tony's advice from a
previous thread a little better, now.

Back to the code window, for a while.

Thanks,
Adam

"joesu" wrote in message
news:f0ffe98.5@WebX.maYIadrTaRb...
> Not a thing, CopyObjects is not needed for what he is trying to
accomplish.
> Joe
> --
>
>
0 Likes
Message 9 of 20

Anonymous
Not applicable
Adam - You don't use CopyObjects() here, you convert the
collections into arrays and you store them instead of the
collections themselves, so that each time need to copy
one of the collections to another document using CopyObjects(),
you just pass the array as the first argument to CopyObjects().

However for this to work, you have to keep each of the
source documents open while you iterate over the target
documents.

Using the CollToVariant() function I posted, and trying
to eliminate some redundancy:

Dim Files(0 To 3) As String
Dim DocArray(0 To 3) As AxDbDocument
Dim arrCase(0 To 3) As Variant

Public Sub Init() ' call this once at load time
Files(0) = "xspsetups.dwg"
Files(1) = "1psetups.dwg"
Files(2) = "20psetups.dwg"
Files(3) = "50psetups.dwg"
End Sub

Private Sub cmdGo_Click()
Dim i As Integer
For i = LBound(Files) To UBound(Files)
Set DocArray(i) = GetInterfaceObject("ObjectDBX.AxDbDocument")
DocArray(i).Open "j:/1049/cad/submit/blocks/" & Files(i)
arrCase(i) = CollToVariant(DocArray(i).PlotConfigurations)
Next i

''rest of sub clipped

' After you're done, clean up and release the AxDbDocuments

For i = LBound(DocArray) to UBound(DocArray)
Set DocArray(i) = Nothing
Next i

End Sub

Later, when you copy the plot configurations to the
destination document (this is not tested and just
gives you a general idea of how to do this using the
array of arrays of plotconfigurations):

' Index is a reference to one of the elements in arrCase

Public Function CopyPCs(Index As Integer, Dest As AxDbDocument) As Variant
Dim PC As AcadPlotConfiguration
Dim PCArray As Variant
PCArray = arrCase(Index)
PC = PCArray(0)
Dim PCs As AcadPlotConfigurations
Set PCs = Dest.PlotConfigurations
While PCs.Count > 0
PCs(i).Delete
WEnd
Dim SourceDoc As Object ' Do NOT use AcadDocument here!!!
Set SourceDoc = PC.Document
CopyPCs = SourceDoc.CopyObjects(PCArray, TargetDoc.PlotConfigurations)
End Function


"Adam Wuellner" wrote in message
news:006071F7D1977F4CE08820B5D770F3D9@in.WebX.maYIadrTaRb...
> I get an 'Argument not optional' error with the following code:
>
> Dim arrCase(0 To 3) As AcadPlotConfigurations
>
> Private Sub cmdGo_Click()
> ''Retrieve standard PlotConfigurations
> ''arrCase is an array of PlotConfigurations Collections
> '' arrCase(0) => Cross Section sheets
> '' arrCase(1) => 1:1 scale
> '' arrCase(2) => 1:20 scale
> '' arrCase(3) => 1:50 scale
> Dim objDbxDoc As Object 'AxDbDocument
> Set objDbxDoc =
> AcadApplication.GetInterfaceObject("ObjectDBX.AxDbDocument")
> objDbxDoc.Open "j:/1049/cad/submit/blocks/xspsetups.dwg"
> arrCase(0) = objDbxDoc.CopyObjects(objDbxDoc.PlotConfigurations)
> objDbxDoc.Open "j:/1049/cad/submit/blocks/1psetups.dwg"
> arrCase(1) = objDbxDoc.CopyObjects(objDbxDoc.PlotConfigurations)
> objDbxDoc.Open "j:/1049/cad/submit/blocks/20psetups.dwg"
> arrCase(2) = objDbxDoc.CopyObjects(objDbxDoc.PlotConfigurations)
> objDbxDoc.Open "j:/1049/cad/submit/blocks/50psetups.dwg"
> arrCase(3) = objDbxDoc.CopyObjects(objDbxDoc.PlotConfigurations)
> Set objDbxDoc = Nothing
> ''rest of sub clipped
> End Sub
>
> The error occurs at the first attempt to set the array element to a
> PlotConfigurations object. That is, the line "arrCase(0) =
> objDbxDoc.CopyObjects(...)".
>
> I can't figure out which argument is missing?
>
> TIA
> Adam Wuellner
> Civiltech Engineering, Inc.
>
>
0 Likes
Message 10 of 20

Anonymous
Not applicable
Oops, one minor correction:

While PCs.Count > 0
PCs(i).Delete
WEnd

Should be:

While PCs.Count > 0
PCs(0).Delete
WEnd

"Tony Tanzillo" wrote in message
news:FD9A081A2529364538EA727484839CB8@in.WebX.maYIadrTaRb...
> Adam - You don't use CopyObjects() here, you convert the
> collections into arrays and you store them instead of the
> collections themselves, so that each time need to copy
> one of the collections to another document using CopyObjects(),
> you just pass the array as the first argument to CopyObjects().
0 Likes
Message 11 of 20

Anonymous
Not applicable
Thank you, Tony.

I just realized the bit about keeping the references to the source drawings
open, and that the use of CopyObjects() looked funny - since I didn't have
an answer for the newowner argument.
Which means that in about another six hours I might actually understand how
this works! Not to get ahead of myself.

Thanks again,
Adam

"Tony Tanzillo" wrote in message
news:8E40E378C460DA329D4837933EF8F3B0@in.WebX.maYIadrTaRb...
> Oops, one minor correction:
>
> While PCs.Count > 0
> PCs(i).Delete
> WEnd
>
> Should be:
>
> While PCs.Count > 0
> PCs(0).Delete
> WEnd
>
> "Tony Tanzillo" wrote in message
> news:FD9A081A2529364538EA727484839CB8@in.WebX.maYIadrTaRb...
> > Adam - You don't use CopyObjects() here, you convert the
> > collections into arrays and you store them instead of the
> > collections themselves, so that each time need to copy
> > one of the collections to another document using CopyObjects(),
> > you just pass the array as the first argument to CopyObjects().
>
>
>
0 Likes
Message 12 of 20

Anonymous
Not applicable
"Tony Tanzillo" wrote in message
news:FD9A081A2529364538EA727484839CB8@in.WebX.maYIadrTaRb...
> Adam - You don't use CopyObjects() here, you convert the
> collections into arrays and you store them instead of the
> collections themselves, so that each time need to copy
> one of the collections to another document using CopyObjects(),
> you just pass the array as the first argument to CopyObjects().
>
> However for this to work, you have to keep each of the
> source documents open while you iterate over the target
> documents.
>
> Using the CollToVariant() function I posted, and trying
> to eliminate some redundancy:
>
> Dim Files(0 To 3) As String
> Dim DocArray(0 To 3) As AxDbDocument
> Dim arrCase(0 To 3) As Variant
>
> Public Sub Init() ' call this once at load time
> Files(0) = "xspsetups.dwg"
> Files(1) = "1psetups.dwg"
> Files(2) = "20psetups.dwg"
> Files(3) = "50psetups.dwg"
> End Sub
>
> Private Sub cmdGo_Click()
> Dim i As Integer
> For i = LBound(Files) To UBound(Files)
> Set DocArray(i) = GetInterfaceObject("ObjectDBX.AxDbDocument")
> DocArray(i).Open "j:/1049/cad/submit/blocks/" & Files(i)
> arrCase(i) = CollToVariant(DocArray(i).PlotConfigurations)
> Next i

So, each elements in arrCase will be a variant, containing another array.
Each element in the sub-arrays will be a PlotConfiguration. That's the part
I think I understand, so hopefully I'm right so far.
Question: Does retrieving the PCs via DocArray(i).PlotConfigurations store a
reference to the element of DocArray that was used? IOW, is it only
necessary to explicitly reference DocArray elements here, or do I need to
somehow point to the source document explicitly later, when I will be adding
the referenced PC's to another drawing?

> ' After you're done, clean up and release the AxDbDocuments
>
> For i = LBound(DocArray) to UBound(DocArray)
> Set DocArray(i) = Nothing
> Next i
>
> End Sub
>
> Later, when you copy the plot configurations to the
> destination document (this is not tested and just
> gives you a general idea of how to do this using the
> array of arrays of plotconfigurations):
>
> ' Index is a reference to one of the elements in arrCase
>
> Public Function CopyPCs(Index As Integer, Dest As AxDbDocument) As Variant
> Dim PC As AcadPlotConfiguration
> Dim PCArray As Variant
> PCArray = arrCase(Index)
> PC = PCArray(0)
> Dim PCs As AcadPlotConfigurations
> Set PCs = Dest.PlotConfigurations
> While PCs.Count > 0
> PCs(i).Delete
> WEnd
> Dim SourceDoc As Object ' Do NOT use AcadDocument here!!!
> Set SourceDoc = PC.Document
> CopyPCs = SourceDoc.CopyObjects(PCArray, TargetDoc.PlotConfigurations)
> End Function

I ask the previous question because I don't see DocArray in this function.
Is it enough to retrieve the info (actually, I guess we're just retrieving a
reference) using the ObjectDBX reference, and store it in a variable? Then,
you can just use the variable to get it again, as long as the OjectDBX
document reference is still open and unchanged?

I'm sorry about my vocabulary, I'm not a trained professional. I'm just
trying to understand what is going on.

Thanks,
Adam
0 Likes
Message 13 of 20

Anonymous
Not applicable
"Adam Wuellner" wrote in message
news:44FB6E9477744DE95E70B0C62C4A023A@in.WebX.maYIadrTaRb...
>
>
> So, each elements in arrCase will be a variant, containing another array.
> Each element in the sub-arrays will be a PlotConfiguration. That's the
part
> I think I understand, so hopefully I'm right so far.
> Question: Does retrieving the PCs via DocArray(i).PlotConfigurations store
a
> reference to the element of DocArray that was used? IOW, is it only
> necessary to explicitly reference DocArray elements here, or do I need to
> somehow point to the source document explicitly later, when I will be
adding
> the referenced PC's to another drawing?

You get the source document from one of the PlotConfiguration
object's Document property. That's what CopyPCs does when it
assigns the value to SourceDoc. The reason that SourceDoc is
not declared as AcadDocument, is because in this case, the
value returned by the PlotConfiguration's Document property is
not an AcadDocument, it's an AxDbDocument.

> >
> > ' Index is a reference to one of the elements in arrCase
> >
> > Public Function CopyPCs(Index As Integer, Dest As AxDbDocument) As
Variant
> > Dim PC As AcadPlotConfiguration
> > Dim PCArray As Variant
> > PCArray = arrCase(Index)
> > PC = PCArray(0)
> > Dim PCs As AcadPlotConfigurations
> > Set PCs = Dest.PlotConfigurations
> > While PCs.Count > 0
> > PCs(i).Delete
> > WEnd
> > Dim SourceDoc As Object ' Do NOT use AcadDocument here!!!
> > Set SourceDoc = PC.Document
> > CopyPCs = SourceDoc.CopyObjects(PCArray,
TargetDoc.PlotConfigurations)
> > End Function
>
> I ask the previous question because I don't see DocArray in this function.
> Is it enough to retrieve the info (actually, I guess we're just retrieving
a
> reference) using the ObjectDBX reference, and store it in a variable?
Then,
> you can just use the variable to get it again, as long as the OjectDBX
> document reference is still open and unchanged?

You would call CopyPCs from the OpenDocument() event, after
you have determined which document's PlotConfigurations you
want to copy. You can use a 'select case' statement like the
one you used earlier.

Private Sub Iterator_OpenDocument(Document As AXDB15Lib.IAxDbDocument)

' preceding code omitted

' Assume that TbScale is assigned and used as the selector:

Dim DocIndex As Integer

Select Case TbScale
Case 0
DocIndex = 0
Case 1
DocIndex = 1
Case 20
DocIndex = 2
Case 50
DocIndex = 3
Case Else
DocIndex = -1
ThisDrawing.Utility.Prompt " Blah blah blah..."

End Select

' Then you just use this:

If DocIndex > -1 then

Dim NewPlotConfigArray As Variant

NewPlotConfigArray = CopyPCs(DocIndex, Document)

' NewPlotConfigArray is now an array holding the
' new copies of the PCs

End If

'.......

End Sub

>
> I'm sorry about my vocabulary,
> I'm not a trained professional.

Welcome to the club 🙂
0 Likes
Message 14 of 20

Anonymous
Not applicable
"Tony Tanzillo" wrote in message
news:878C3C71D7AA8605460F4976B22C086D@in.WebX.maYIadrTaRb...
> The reason that SourceDoc is
> not declared as AcadDocument, is because in this case, the
> value returned by the PlotConfiguration's Document property is
> not an AcadDocument, it's an AxDbDocument.


Why not declare it As AxDbDocument? I've seen this commented out in favor
of Object, before. Are there bugs/issues with AxDbDocument?
0 Likes
Message 15 of 20

Anonymous
Not applicable
Code portability.

If you declare it as either AcadDocument or AxDbDocument,
then you're locked into using it with either one or the
other, but not both.

"Adam Wuellner" wrote in message
news:4006DF8162757EB8E26098C4B2BE1373@in.WebX.maYIadrTaRb...
>
> "Tony Tanzillo" wrote in message
> news:878C3C71D7AA8605460F4976B22C086D@in.WebX.maYIadrTaRb...
> > The reason that SourceDoc is
> > not declared as AcadDocument, is because in this case, the
> > value returned by the PlotConfiguration's Document property is
> > not an AcadDocument, it's an AxDbDocument.
>
>
> Why not declare it As AxDbDocument? I've seen this commented out in favor
> of Object, before. Are there bugs/issues with AxDbDocument?
>
>
0 Likes
Message 16 of 20

Anonymous
Not applicable
Tony,

I just finished applying the changes you recommended throughout the course
of this thread. The program works wonderfully. The speed issue
disappeared, my guess is that's due to not opening the source drawings in
each iteration.

Thanks again for all of your help. This DocumentIterator is going to be a
powerful addition to my personal arsenal.

Adam Wuellner
Civiltech Engineering, Inc.

BTW, "Mastering AutoCAD R13" is still an indispensable book in my library,
right up there with the Tufte trilogy.

"Tony Tanzillo" wrote in message
news:D693F47664ECDFC0788471BA5624CFEE@in.WebX.maYIadrTaRb...
> Code portability.
>
> If you declare it as either AcadDocument or AxDbDocument,
> then you're locked into using it with either one or the
> other, but not both.
>
> "Adam Wuellner" wrote in message
> news:4006DF8162757EB8E26098C4B2BE1373@in.WebX.maYIadrTaRb...
> >
> > "Tony Tanzillo" wrote in message
> > news:878C3C71D7AA8605460F4976B22C086D@in.WebX.maYIadrTaRb...
> > > The reason that SourceDoc is
> > > not declared as AcadDocument, is because in this case, the
> > > value returned by the PlotConfiguration's Document property is
> > > not an AcadDocument, it's an AxDbDocument.
> >
> >
> > Why not declare it As AxDbDocument? I've seen this commented out in
favor
> > of Object, before. Are there bugs/issues with AxDbDocument?
> >
> >
>
>
0 Likes
Message 17 of 20

Anonymous
Not applicable
Adam - Glad it worked out for you (and it's Maximizing
AutoCAD R13 that I co-Authored).

"Adam Wuellner" wrote in message
news:8EEE3F947F6BFDB65F6EEBF3AB94C9E1@in.WebX.maYIadrTaRb...
> Tony,
>
> I just finished applying the changes you recommended throughout the course
> of this thread. The program works wonderfully. The speed issue
> disappeared, my guess is that's due to not opening the source drawings in
> each iteration.
>
> Thanks again for all of your help. This DocumentIterator is going to be a
> powerful addition to my personal arsenal.
>
> Adam Wuellner
> Civiltech Engineering, Inc.
>
> BTW, "Mastering AutoCAD R13" is still an indispensable book in my library,
> right up there with the Tufte trilogy.
>
0 Likes
Message 18 of 20

Anonymous
Not applicable
"Tony Tanzillo" wrote in message
news:4AF47DD95DB46EB8C31FB39C69970D51@in.WebX.maYIadrTaRb...
> Adam - Glad it worked out for you (and it's Maximizing
> AutoCAD R13 that I co-Authored).

That's what I meant.

Anyway, I discovered a problem. I posted my last message without actually
opening up one the destination drawing to confirm the work. The pagesetups
are, in fact, listed properly in the Page Setup Name list (on the plot
dialog). They are visible to other routines I have that test for
pagesetups. However, when I selected one from the Page Setup Name list, I
get an 'Error: Unable to find Named Plot Setting' alert box. Any idea what
may be causing this?

I'll reprint the portions of the code that deal with the copying:

'---Start Code
Private Sub Iterator_OpenDocument(Document As AXDB15Lib.IAxDbDocument)
'...
' DocIndex is already appropriately resolved
If DocIndex > -1 Then
Dim NewPlotConfigArray As Variant
NewPlotConfigArray = CopyPcs(DocIndex, Document)
' NewPlotConfigArray is now an array holding the
' new copies of the PCs
End If

Document.SaveAs Document.Name

End Sub

Public Function CopyPcs(Index As Integer, Dest As AxDbDocument) As Variant
'provided by Tony Tanzillo
Dim PC As AcadPlotConfiguration
Dim PCArray As Variant
PCArray = arrCase(Index)
Set PC = PCArray(0)

Dim PCs As AcadPlotConfigurations
Set PCs = Dest.PlotConfigurations
While PCs.Count > 0
PCs(0).Delete
Wend

Dim SourceDoc As Object
Set SourceDoc = PC.Document

CopyPcs = SourceDoc.CopyObjects(PCArray, PCs)
'Tony - On the above line, you had TargetDoc.PlotConfigurations in place
of PCs
End Function


Private Sub cmdGo_Click()

Me.Hide
Init 'fills the Files array

''Retrieve standard PlotConfigurations
Dim i As Integer
For i = LBound(Files) To UBound(Files)
Set DocArray(i) = GetInterfaceObject("ObjectDBX.AxDbDocument")
DocArray(i).Open "j:/1049/cad/submit/blocks/" & Files(i)
arrCase(i) = CollToVariant(DocArray(i).PlotConfigurations)
Next i

Set Iterator = GetInterfaceObject("AcadX.DocumentIterator")
Iterator.folder = txtFolder.Value
Iterator.Recursive = chkRecursive.Value
Iterator.ReadOnly = chkReadOnly.Value
Iterator.Execute

For i = LBound(DocArray) To UBound(DocArray)
Set DocArray(i) = Nothing
Next i

ThisDrawing.Utility.Prompt "--DONE--" & vbCrLf
Unload Me

End Sub
'---End Code

Thanks for any insight.
Adam
0 Likes
Message 19 of 20

Anonymous
Not applicable
Looks like the PlotConfigurations are referencing something that's
not coming along for the ride, when you do the CopyObjects().

Technically, AutoCAD should be handling this, but I seem to
recall that there was some issue with copying plot configs
(or layouts?).

Can you email me a drawing that contains the copied PCs?


"Adam Wuellner" wrote in message
news:02D7B87E5E6BF0644FE430797B08842E@in.WebX.maYIadrTaRb...
> "Tony Tanzillo" wrote in message
> news:4AF47DD95DB46EB8C31FB39C69970D51@in.WebX.maYIadrTaRb...
> > Adam - Glad it worked out for you (and it's Maximizing
> > AutoCAD R13 that I co-Authored).
>
> That's what I meant.
>
> Anyway, I discovered a problem. I posted my last message without actually
> opening up one the destination drawing to confirm the work. The
pagesetups
> are, in fact, listed properly in the Page Setup Name list (on the plot
> dialog). They are visible to other routines I have that test for
> pagesetups. However, when I selected one from the Page Setup Name list, I
> get an 'Error: Unable to find Named Plot Setting' alert box. Any idea
what
> may be causing this?
>
> I'll reprint the portions of the code that deal with the copying:
>
> '---Start Code
> Private Sub Iterator_OpenDocument(Document As AXDB15Lib.IAxDbDocument)
> '...
> ' DocIndex is already appropriately resolved
> If DocIndex > -1 Then
> Dim NewPlotConfigArray As Variant
> NewPlotConfigArray = CopyPcs(DocIndex, Document)
> ' NewPlotConfigArray is now an array holding the
> ' new copies of the PCs
> End If
>
> Document.SaveAs Document.Name
>
> End Sub
>
> Public Function CopyPcs(Index As Integer, Dest As AxDbDocument) As Variant
> 'provided by Tony Tanzillo
> Dim PC As AcadPlotConfiguration
> Dim PCArray As Variant
> PCArray = arrCase(Index)
> Set PC = PCArray(0)
>
> Dim PCs As AcadPlotConfigurations
> Set PCs = Dest.PlotConfigurations
> While PCs.Count > 0
> PCs(0).Delete
> Wend
>
> Dim SourceDoc As Object
> Set SourceDoc = PC.Document
>
> CopyPcs = SourceDoc.CopyObjects(PCArray, PCs)
> 'Tony - On the above line, you had TargetDoc.PlotConfigurations in place
> of PCs
> End Function
>
>
> Private Sub cmdGo_Click()
>
> Me.Hide
> Init 'fills the Files array
>
> ''Retrieve standard PlotConfigurations
> Dim i As Integer
> For i = LBound(Files) To UBound(Files)
> Set DocArray(i) = GetInterfaceObject("ObjectDBX.AxDbDocument")
> DocArray(i).Open "j:/1049/cad/submit/blocks/" & Files(i)
> arrCase(i) = CollToVariant(DocArray(i).PlotConfigurations)
> Next i
>
> Set Iterator = GetInterfaceObject("AcadX.DocumentIterator")
> Iterator.folder = txtFolder.Value
> Iterator.Recursive = chkRecursive.Value
> Iterator.ReadOnly = chkReadOnly.Value
> Iterator.Execute
>
> For i = LBound(DocArray) To UBound(DocArray)
> Set DocArray(i) = Nothing
> Next i
>
> ThisDrawing.Utility.Prompt "--DONE--" & vbCrLf
> Unload Me
>
> End Sub
> '---End Code
>
> Thanks for any insight.
> Adam
>
>
0 Likes
Message 20 of 20

Anonymous
Not applicable
Adam - It looks like CopyObjects() cannot be used to copy
plot configurations. I suppose that you're going to need
to go back to using Add() and then CopyFrom() to do it.

I remember it more clearly now, that I had the same problem
when trying to copy them to a new drawing. The result was
always an empty dictionary.

It shouldn't be too hard to do using Add() and CopyFrom(),
using the existing AxDbDocument's PlotConfigurations as
the source. Let me know if you run into trouble.


"Adam Wuellner" wrote in message
news:02D7B87E5E6BF0644FE430797B08842E@in.WebX.maYIadrTaRb...
>
> Anyway, I discovered a problem. I posted my last message without actually
> opening up one the destination drawing to confirm the work. The
pagesetups
> are, in fact, listed properly in the Page Setup Name list (on the plot
> dialog). They are visible to other routines I have that test for
> pagesetups. However, when I selected one from the Page Setup Name list, I
> get an 'Error: Unable to find Named Plot Setting' alert box. Any idea
what
> may be causing this?
>
0 Likes