PDA

View Full Version : "invalid owner object" Error



david.brissenden
2008-11-27, 09:30 AM
Has anyone successfully used the CopyObjects method?

I get an error "Invalid Owner Object" when I run this:

Dim objContainFile As AcadDocument
Dim CopyObjects(1) As AcadBlock

Set objContainFile = ThisDrawing.Application.Documents.Open("T:\Border.dwg")

Set CopyObjects(0) = objContainFile.Blocks.Item("WD_M")
Set CopyObjects(1) = objContainFile.Blocks.Item("WD_PNLM")

objContainFile.CopyObjects CopyObjects, ThisDrawing.Blocks

Anyone know what that means? Help files don't seem to be very helpful.

Thanks

seant61
2008-11-27, 10:39 AM
What if this change were made:

Dim CopyObjects(1) As Object

david.brissenden
2008-11-27, 11:01 AM
What if this change were made:

Dim CopyObjects(1) As Object
Unfortunately not. Still the same :(

seant61
2008-11-27, 12:54 PM
This is interesting. It seems there is a rather unintuitive setup required. Try:



. . . .
Dim RecieverDocSpace As AcadBlock
. . . .

Set RecieverDocSpace = ThisDrawing.ModelSpace
Set objContainFile = ThisDrawing.Application.Documents.Open("T:\Border.dwg") 'now becomes ThisDrawing

. . . .

objContainFile.CopyObjects CopyObjects, RecieverDocSpace 'Transfered to original drawings Blocks, will need insert to actually show in MS

david.brissenden
2008-11-27, 01:17 PM
This is interesting. It seems there is a rather unintuitive setup required. Try:



. . . .
Dim RecieverDocSpace As AcadBlock
. . . .

Set RecieverDocSpace = ThisDrawing.ModelSpace
Set objContainFile = ThisDrawing.Application.Documents.Open("T:\Border.dwg") 'now becomes ThisDrawing

. . . .

objContainFile.CopyObjects CopyObjects, RecieverDocSpace 'Transfered to original drawings Blocks, will need insert to actually show in MS


Hi seant61,

Thanks for that...it is rather unintuitive isn't it :(

The message has gone away now but it still doesn't work with regard to copying the blocks across, so thats something i'll have to look into.

Thanks again

david.brissenden
2008-11-27, 05:30 PM
Well this is what I have so far...

Set RecieverDocSpace = ThisDrawing.ModelSpace
Set objContainFile = ThisDrawing.Application.Documents.Open("T:\BLBorder.dwg")

Set CopyObjects(0) = objContainFile.Blocks.Item("WD_M")
Set CopyObjects(1) = objContainFile.Blocks.Item("WD_PNLM")

retvar = objContainFile.CopyObjects(CopyObjects, RecieverDocSpace)

objContainFile.Close False


Although it doesn't bring up the original error, it does not copy the blocks either!! :banghead:

As far as I can see I have done everything in the help files and what seant61was kind enough to suggest but I just cannot see what the problem is!!

Anyone any further ideas?

seant61
2008-11-28, 09:18 AM
To clarify, the lines of code in my last post only transferred the items in “CopyObjects” (presumably blocks WD_M and WD_PNLM) from objContainFile to the original documents Block collection.

The part that is a bit odd is that the transfer required access to the collection through Modelspace – the blocks have not been inserted into Modelspace. At this stage the blocks are ready for insertion i.e., are visible only as options from the INSERT command.

To actually insert them via code would require:


Dim entRef As AcadBlockReference
Dim dblInsPt(0 to 2) as Double

. . . .

Set entRef = ThisDrawing.ModelSpace.InsertBlock(dblInsPt, " WD_M", 1#, 1#, 1#, 0#)

david.brissenden
2008-11-28, 11:26 AM
To clarify, the lines of code in my last post only transferred the items in “CopyObjects” (presumably blocks WD_M and WD_PNLM) from objContainFile to the original documents Block collection.

The part that is a bit odd is that the transfer required access to the collection through Modelspace – the blocks have not been inserted into Modelspace. At this stage the blocks are ready for insertion i.e., are visible only as options from the INSERT command.

To actually insert them via code would require:


Dim entRef As AcadBlockReference
Dim dblInsPt(0 to 2) as Double

. . . .

Set entRef = ThisDrawing.ModelSpace.InsertBlock(dblInsPt, " WD_M", 1#, 1#, 1#, 0#)


Oh!! I see :) now!!

I shall try inserting the blocks and see how I get on.

Thanks