C# .GetXData(string, object, object);

C# .GetXData(string, object, object);

Anonymous
Not applicable
1,121 Views
2 Replies
Message 1 of 3

C# .GetXData(string, object, object);

Anonymous
Not applicable

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

0 Likes
Accepted solutions (1)
1,122 Views
2 Replies
Replies (2)
Message 2 of 3

norman.yuan
Mentor
Mentor
Accepted 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&colon; " + v.ToString());

              break;

            case ....

        }

    )

}

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 3 of 3

Anonymous
Not applicable

Hi Norman, thank you that is just what I was after.

0 Likes