PDA

View Full Version : how to get an entity's object data and change another entity's object data?



reecho_cd
2009-04-15, 02:42 PM
My program is under autodeskmap2005 and c#2005.I want to get an entity's object data ,and then set this entity's object data to another entity.Now I don't know how to get the object data from an entity .Please help me!Thank you very much!

Sorry for my poor english.

My code is list as follows:

//select source entity
object select = null;
object basePnt = null;
acadApp.ActiveDocument.Utility.GetEntity(out select, out basePnt, "select source entity:");
AcadEntity sourceEntity = select as AcadEntity;

//select target entity
object select2 = null;
object basePnt2 = null;
acadApp.ActiveDocument.Utility.GetEntity(out select2, out basePnt2, "select target entity:");
AcadEntity targetEntity= select2 as AcadEntity;

// get datatable of sourceentity
AutocadMAP.AcadMap map = acadApp.GetInterfaceObject("AutoCADMap.Application") as AcadMap; AutocadMAP.Project p = map.Projects.Item(0);
string sourceEntityTableName = "";
//how to get sourceentity's objectdata's tablename?I cann't work it out.
AutocadMAP.ODTable table = p.ODTables.Item(sourceEntityTableName);
AutocadMAP.ODRecords records = table.GetODRecords();

records.Init(targetEntity, true, false);
//assign sourceentity's objectdata to targetEntity;I didn't test the sentence.This sentence must be wrong