Hello,
How can I read the data that comes out of .GetXData when using C#. The out is a an object???
foreach (AcadEntity ent in doc.PaperSpace)
{
Object xdataType;
Object xdatavalue;
ent.GetXData("test", out xdataType, out xdatavalue);
//how do i read xdatavalue???
}
Regards
Chris
Solved! Go to Solution.
Solved by norman.yuan. Go to Solution.
The output objects (xdataType and xdatavalue) would be either null, or array with at least 1 element (application name). So, you simply cast them as array and loop through them. Something like:
ent.GetXData("test", out xdataType, out xdatavalue);
if (xdataType!=null && xdatavalue!=null)
{
short[] dTypes=xdataType as short[];
object[] dValues=xdatavalue as object[];
for (int i=0; i<dTypes.Length; i++)
{
short t=dTypes[i];
object v=dValues[i];
switch (t)
{
case 1001:
MessageBox.Show("This is app name: " + v.ToString());
break;
case 1000:
MessageBox.Show("This is text value in XData: " + v.ToString());
break;
case ....
}
)
}
Norman Yuan