DBText entResult = (DBText)trans.GetObject(sh.ResultObjectId, OpenMode.ForRead); //可能有问题,将BlockId修改成OwnerId后没有问题 //下面这个就有问题,得到的是BlockTableRecord,不能强制转换成BlockReference //BlockReference blkResult = (BlockReference)trans.GetObject(entResult.BlockId, OpenMode.ForRead); //下面这个没有问题 BlockReference blkResult = (BlockReference)trans.GetObject(entResult.OwnerId, OpenMode.ForRead); BlockTableRecord btr = (BlockTableRecord)trans.GetObject(blkResult.BlockTableRecord, OpenMode.ForRead);
ID:指其本身的objectid
BlockId:指其所在的块定义的id
OwnerId:指其所在的块参照的id
初学者肯定比较晕