Reading object data from dwg file

Reading object data from dwg file

Anonymous
Not applicable
883 Views
2 Replies
Message 1 of 3

Reading object data from dwg file

Anonymous
Not applicable
Hi,

Does anyone know how can read object data from a dwg file using c# or c++?

regards,
anant Edited by: apt42 on Jun 5, 2009 3:37 PM
0 Likes
884 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable

Look in the Map3D SDK samples there are one or two
examples in there.


 

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Hi,
Does anyone know how can read object data from a dwg file using c# or c++?
regards, anant Edited by: apt42 on Jun 5, 2009 3:37
PM
0 Likes
Message 3 of 3

masanisreekar
Observer
Observer
anant,

you can find lot of samples in \Map ObjectARX SDK 2009\Map Samples\DotNet\ObjectDataCS

I am giving some code which worked for me for Map3D 2007. try this.

[CommandMethod("OdShow")]
public void ShowData()
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
PromptEntityOptions pe = new PromptEntityOptions("Select Entity..: ");
PromptEntityResult pr = ed.GetEntity(pe);
if (pr.Status == PromptStatus.OK)
{
Autodesk.AutoCAD.ApplicationServices.TransactionManager tm = Application.DocumentManager.MdiActiveDocument.TransactionManager;
Transaction tr = tm.StartTransaction();
Entity en = (Entity)tm.GetObject(pr.ObjectId, OpenMode.ForRead);

MapApplication mapApp = HostMapApplicationServices.Application;
Tables tables = mapApp.ActiveProject.ODTables;
Records recs = tables.GetObjectRecords(0, en.ObjectId, Autodesk.Gis.Map.Constants.OpenMode.OpenForRead,true);
ed.WriteMessage("\n");
foreach (Record rec in recs)
{
Autodesk.Gis.Map.ObjectData.Table tbl = tables[rec.TableName.ToString()];
FieldDefinitions fldDef = tbl.FieldDefinitions;
ed.WriteMessage("\n");
ed.WriteMessage(rec.TableName.ToString());
ed.WriteMessage("\n");
ed.WriteMessage("--------------------");
ed.WriteMessage("\n");
for (int i = 0; i < fldDef.Count; i++)
{
ed.WriteMessage(fldDef.Name.ToString() + " : " + getValasStrig(rec));
ed.WriteMessage("\n");
}

ed.WriteMessage("\n");
}
}
}

Sreekar Masani.
0 Likes