VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
Anonymous
899 Views, 2 Replies

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

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

2 REPLIES 2
Message 2 of 3
norman.yuan
in reply to: Anonymous

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

Message 3 of 3
Anonymous
in reply to: norman.yuan

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

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

Post to forums  

Autodesk Design & Make Report

”Boost