Author Topic: List to XData  (Read 2611 times)

0 Members and 1 Guest are viewing this topic.

cadpro

  • Guest
List to XData
« on: December 07, 2011, 11:26:30 AM »
Hi,

I have a list of custom data type. I want to add this to an entity XData. Is it possible?

Thanks

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: List to XData
« Reply #1 on: December 07, 2011, 12:11:17 PM »
Depends on the "custom data".  You will need to convert it to one of the organized types in XData (check the AutoCAD DXF reference for code ranges and applicable types).  For example, if your custom type contains a couple of INTs, a boolean, and a string then its pretty simple to chain it together.  Most types are supported in one format or another, plus a few AutoCAD-centric types like object references.  I *think* there's a section in there for binary storage, but watch out for the XData size limits.
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

cadpro

  • Guest
Re: List to XData
« Reply #2 on: December 07, 2011, 06:02:03 PM »
I have converted the list to contain strings. The entity already has XData in it. I want to add the strings in the list too to the XData. Could someone please help me on how I could add this list as XData?

Thanks

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: List to XData
« Reply #3 on: December 08, 2011, 01:27:16 AM »
Hi,

With .NET, xdatas are stored in ResultBuffers.
You can get the existing xdata with the GetXDataForApplication() method.

Code: [Select]
ResultBuffer datas = ent.GetXDataForApplication("regAppName");
Then add your datas at the end of the ResultBuffer

Code: [Select]
foreach (string s in strList)
{
    datas.Add(new TypedValue(1000, s));
}

Update the entity xdata
Code: [Select]
ent.XData = datas;
Speaking English as a French Frog

cadpro

  • Guest
Re: List to XData
« Reply #4 on: December 08, 2011, 04:33:02 AM »
I do not know what "regappname" is? Or is it that I can just put any string value in there?

Thanks

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: List to XData
« Reply #5 on: December 08, 2011, 10:49:35 AM »
XData uses a "registered application name" i.e. regapp to keep the data from diffierent applications separate.  That way, you can call a select set of XData off an entity by providing a specific regapp name instead of getting all XData from all applications.  I would suggest something definititive for a name that reflects both yourself and your corporate/personal entity, should you decide to provide other applications which could possible add more data.
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

cadpro

  • Guest
Re: List to XData
« Reply #6 on: December 09, 2011, 03:48:19 PM »
XData uses a "registered application name" i.e. regapp to keep the data from diffierent applications separate.  That way, you can call a select set of XData off an entity by providing a specific regapp name instead of getting all XData from all applications.  I would suggest something definititive for a name that reflects both yourself and your corporate/personal entity, should you decide to provide other applications which could possible add more data.

Great explanation! Thank You so much dgorsman!