本案例为:将当前cad图中实体复制到另一个cad的块中,并插入块。
目前代码尚未调试成功,找bug中......
public class Demo
{
[CommandMethod("xx1")]
public void XXA()
{
// 获取当前文档和数据库
Document currentDoc = Application.DocumentManager.MdiActiveDocument;
Database currentDb = currentDoc.Database;
Editor ed = currentDoc.Editor;
// 定义块名称
string blockName = "ExportedBlock";
try
{
// 存储模型空间对象的 ObjectId 到数组中
ObjectIdCollection objectIds = new ObjectIdCollection();
using (Transaction tr = currentDb.TransactionManager.StartTransaction())
{
BlockTable bt = (BlockTable)tr.GetObject(currentDb.BlockTableId, OpenMode.ForRead);
BlockTableRecord modelSpace = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.