0

I am using AlignedDimension object of Autodesk.AutoCAD.DatabaseServices to create objects in autocad. I want to store some data in XData of Dimension object using TypedValue object. But when we assign the resultBuffer to XData it does not assign the value to XData.

This works fine if the object is Entity But xData is not getting assigned for AlignedDimension object.

Can you please help me assign typedValue to Xdata of AlignedDimension?

Below is the code snippet:

 List<TypedValue> xdata = new List<TypedValue>();
 xdata.Add(new TypedValue(872, "ACF"));
 DBObject object1= acTrans.GetObject(newDimension.ObjectId, OpenMode.ForWrite) as Dimension;
 ResultBuffer resBuffer = new ResultBuffer(xdata.ToArray());
 object1.XData = resBuffer;  
Hiura
  • 3,500
  • 2
  • 20
  • 39
ashwini
  • 1
  • 1
  • 2

1 Answers1

0

To assign xData you'll need to define a application (under RegAppTable) and use this as the first TypedValue on your list.

See a sample at http://through-the-interface.typepad.com/through_the_interface/2007/04/adding_xdata_to.html


static void AddRegAppTableRecord(string regAppName)
    {
      Document doc =
        Application.DocumentManager.MdiActiveDocument;
      Editor ed = doc.Editor;
      Database db = doc.Database;

      Transaction tr =
        doc.TransactionManager.StartTransaction();
      using (tr)
      {
        RegAppTable rat =
          (RegAppTable)tr.GetObject(
            db.RegAppTableId,
            OpenMode.ForRead,
            false
          );
        if (!rat.Has(regAppName))
        {
          rat.UpgradeOpen();
          RegAppTableRecord ratr =
            new RegAppTableRecord();
          ratr.Name = regAppName;
          rat.Add(ratr);
          tr.AddNewlyCreatedDBObject(ratr, true);
        }
        tr.Commit();
      }
    }
Augusto Goncalves
  • 8,493
  • 2
  • 17
  • 44