CopyObjects in COM return Invalid Object Array

CopyObjects in COM return Invalid Object Array

a_minet
Participant Participant
1,040 Views
1 Reply
Message 1 of 2

CopyObjects in COM return Invalid Object Array

a_minet
Participant
Participant

Good morning all,

 

I'm trying to make an .exe application that uses the library:
- Autodesk.AutoCAD.Interop.Common.dll
- Autodesk.AutoCAD.Interop.dll

 

I define all my variables in dynamic to be able to launch the application on any AutoCAD and I am not referring to the 2 dlls in my application.

 

But I am having a problem on this line:

 

dynamic /* AcadDimAligned */ dimension = doc.ModelSpace.AddDimAligned(
new double [3] {200, 0, 0},
new double [3] {200, 100, 0},
new double [3] {200, 100/2, 0});

dynamic[] po_array = new dynamic [1];
po_array[0] = dimension;

dynamic /*AcadBlockReference*/ fullBlockRefObj = doc.ModelSpace.InsertBlock (location, blockSectionName, 1.0, 1.0, 1.0, 0);

doc.CopyObjects (po_array, fullBlockObj);

 

The last line gives me an exception: "Invalid objects array"

 

This works when I reference the 2 dlls and set the po_array array to AcadEntity [], but this only works in 2019 and 2020 the references used are 2020 but this does not work in 2018.

 

Avez vous une solution à ce problème?

 

Is it possible to dynamically load the dlls:
- Autodesk.AutoCAD.Interop.Common.dll
- Autodesk.AutoCAD.Interop.dll
depending on the version of AutoCAD started?

0 Likes
Accepted solutions (1)
1,041 Views
1 Reply
Reply (1)
Message 2 of 2

Norman_Yuan
Mentor
Mentor
Accepted solution

It looks to me, regardless the error you got, that AutoCAD cannot do what you want: adding a dimension (or any type of entity other than AcadAttributeReference, for that matter) to a block reference. Block reference, as owner, CAN ONLY own attributes, nothing else.

Norman Yuan

Drive CAD With Code

EESignature