.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

set Data field on Xrecord

0 REPLIES 0
Reply
Message 1 of 1
base2
239 Views, 0 Replies

set Data field on Xrecord

Hi,
i have a strange problem when I try to set the field Xrecord.Data and assign to it a resbuf.
1) At first I see that the follow row:

Xrecord xrec = new Xrecord();

work fine, but the member Data of xrec generate an exception 'System.InvalidOperationException'.
this always and also with the autodesk samples.
Why? It's correct?

2) I do to set a resbuf made with some objectid values and store it with an xrecord,
my code:
------------------------
ResultBuffer rb = new ResultBuffer();
foreach (ObjectId id in objidcolGroup)
rb.Add(new TypedValue((int)resbufCode.RTENAME, id)); // resbufCode.RTENAME int 5600

TypedValue[] ti = rb.AsArray();

Xrecord xrec = new Xrecord();
xrec.Data = new ResultBuffer(ti);
------------------------
the resultbuffer rb it's ok but the row:
xrec.Data = new ResultBuffer(ti);
cause an exception of System.InvalidOperationException and I not see by the debugger the value of field xrec.Data,
anywhere if I store this xrecord in autocad dwg, I don't have error and I can also retrive his value correctly.

I try to chage my code in:
ResultBuffer rb = new ResultBuffer();
int number = 5;
foreach (ObjectId id in objidcolGroup)
rb.Add(new TypedValue((int)resbufCode.RTSHORT, number)); // resbufCode.RTENAME int 5600

TypedValue[] ti = rb.AsArray();

Xrecord xrec = new Xrecord();
xrec.Data = rb; // or "new ResultBuffer(ti);"

I have always the first exception on xrec = new xrecord() but
I don't have the exception on row
xrec.Data = rb; // or "new ResultBuffer(ti);"
and in the debugger I see on xrec.Data his correct values

is the problem on creation of resultbuffer with objectid value?
what is the best way to do this?

thanks in advance
andrea
0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost