Yes, of course. I was doing a little bit more testing, and it seems like the problem is that im trying to run this inside the event hendler. Im thinking this becouse Entity ent = senderObj as Entity;
ObjectId id = ent.ObjectId;
and ObjectId[] ids = result.Value.GetObjectIds();
ids[0]
when converted to string spits out the same ObjectID number.
public bool AddODRecord(Tables tables, string tableName, ObjectId id, string value)
{
try
{
Autodesk.Gis.Map.ObjectData.Table table = tables[tableName];
// Create and initialize an record
Record tblRcd = Record.Create();
table.InitRecord(tblRcd);
MapValue val = tblRcd[0]; // String type
val.Assign(value);
table.AddRecord(tblRcd, id);
return true;
}
catch (MapException)
{
return false;
}
}
public void UpdateOD(string TableName, ObjectId objectID, string columnName, string value)
{
Autodesk.Gis.Map.ObjectData.Tables tables = Autodesk.Gis.Map.HostMapApplicationServices.Application.ActiveProject.ODTables;
Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
using (Records records = tables.GetObjectRecords(0, objectID, Autodesk.Gis.Map.Constants.OpenMode.OpenForWrite, false))
{
if (records.Count == 0)
{
ed.WriteMessage("\nData attachment failed.");
return;
}
foreach (Record Recd in records)
{
Autodesk.Gis.Map.ObjectData.Table tbl = tables[Recd.TableName];
if (tbl.Name.CompareTo(TableName) == 0)
{
for (int i = 0; i < Recd.Count; i++)
{
FieldDefinitions tblDefs = tbl.FieldDefinitions;
FieldDefinition column = null;
column = tblDefs[i];
if (column.Name.CompareTo(columnName) == 0)
{
Recd[i].Assign(value);
records.UpdateRecord(Recd);
break;
}
}
}
}
}