AutoCAD Plant3d 數(shù)據(jù)讀取(類似Revit的Lookup) (一)
背景
在Plant3d的開(kāi)發(fā)過(guò)程中,發(fā)現(xiàn)缺少一個(gè)類似revit的信息查看工具,同時(shí)做一些數(shù)據(jù)驗(yàn)證
思路
- 啟動(dòng)拾取
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
PromptEntityResult res = ed.GetEntity("\n選擇一個(gè)實(shí)體: ");
- 讀取信息
using (Transaction transaction = dwg.TransactionManager.StartTransaction())
{
DBObject ent = transaction.GetObject(res.ObjectId, OpenMode.ForRead);
if (ent == null)
{
return string.Empty;
}
if (res.ObjectId.ObjectClass.IsDerivedFrom(RXObject.GetClass(typeof(Pipe))))
{
return Read(ent as Pipe);
}
else if (res.ObjectId.ObjectClass.IsDerivedFrom(RXObject.GetClass(typeof(Equipment))))
{
return Read(ent as Equipment);
}
return "未識(shí)別對(duì)象";
}
每多學(xué)一點(diǎn)知識(shí),就少寫(xiě)一行代碼
浙公網(wǎng)安備 33010602011771號(hào)