第一个 resbuf 是 AutoCAD API 的 ADS 版本,它是一个 C API。ObjectARX 是 AutoCAD API 的 C++ 版本,仍将 resbuf 用于 XData,但不再用于实体属性访问。在 ObjectARX (C++) 和 AutoCAD .Net API (C#/VB.Net) 中,您可以分别使用特定的方法和访问器访问实体属性(参见底部的示例)。
使用DXF 表读取 resbuf 链表中的代码。
其次,代码 DXF 410 只是一个字符串。如果他愿意,有人可以使用它并存储层名称,但实体层由 DXF 代码 8 引用。
最后的 DXF 代码 10,表示实体的第一个有意义的点。这可以是圆的中心,也可以是直线的第一个点,等等...这就是为什么使用 resbuf 需要更多的关注和了解底层 AutoCAD 数据库结构的组织方式,而不是使用访问器。
例如:
广告 (C)
ads_name en ;
ads_point pt ;
acedEntSel ("\nSelect an Entity: ", en, pt) ; // was ads_entsel() long time ago
struct resbuf *res =acdbEntGet (en) ;
// ... do something with res parsing the linked list and search for specific codes
// Entity Layer is code 8
// ... Eventually push changes to the entity using acdbEntMod()
ObjectARX (C++)
ads_name en ;
ads_point pt ;
acedEntSel ("\nSelect an Entity: ", en, pt) ; // was ads_entsel() long time ago
AcDbObjectId id ;
acdbGetObjectId (id, en) ;
AcDbObjectPointer<AcDbEntity> pEnt (id, AcDb::kForWrite) ;
AcDbObjectId layerId =pEnt->layerId () ;
// ... do something with pEnt ...
// Eventually set a new layer
pEnt->setLayer (newLayerId, true) ;
AutoCAD .Net (C#)
Document doc =Application.DocumentManager.MdiActiveDocument ;
Database db =doc.Database ;
Editor ed =doc.Editor ;
PromptSelectionResult psr =ed.GetSelection () ;
SelectionSet ss =psr.Value ;
SelectedObject so =ss [0] ;
Transaction tr =doc.TransactionManager.StartTransaction () ;
Entity ent =tr.GetObject (so.ObjectId, OpenMode.ForWrite) as Entity ;
ObjectId layerId =ent.Layer ;
// ... do something with ent ...
// Eventually set a new layer
ent.Layer =newLayer ;
tr.Commit () ;
// Regen clears highlighting and reflects the new layer
ed.Regen () ;