你可以把BlockTableRecord想象成一个容器。(“ModelSpace”“PaperSpace”)也是BlockTableRecords。
blocktableRecord中拥有或包含的实体具有层属性
因此,一个插座块(典型的双工符号)BlockTableRecord将包含一个圆(实体)和两条线(实体),这将具有层属性。(通常在图层0上绘制)
您看到的可见实体是BlockReference,它是blocktablerecord内实体的实例,将具有层属性(Insert命令)
如果有帮助的话 在BlockTableRecord的不同层上可以有实体,但要冻结“块”,必须冻结BlockReference所在的层
因此,如果使用Autocad UI创建一个块,在不同的图层上有3条不同颜色的线。
然后将其插入一个层,您必须冻结该层。
从您的代码和帖子中,我猜您正在将实体添加到ModelSpace BlockTableRecord中。
因此,块引用只是添加到ModelSpace blocktablerecord实体集合中的另一个实体。
(ModelSpace BlockTableRecord具有其他功能、属性等……布局、视口等)
如果你想让我张贴代码,可能有助于显示或解释,我很乐意。
我想你更喜欢看你的帖子
谢谢杰夫!你是对的。
我创建了不同的实体(例如cirlce、point),并将每个实体分配到一个单独的层,以便可以分别冻结和解冻它们。然后,我向BlockTable添加了一个blockreference,它引用了包含实体的blocktablerecord,并将blockreference分配给了一个新层。因此,当我冻结新层时,所有实体都被隐藏。
此代码适用于我:
// Open the Block table for read
BlockTable acBlkTbl;
acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId,
OpenMode.ForRead) as BlockTable;
// Create our new block table record...
BlockTableRecord btr = new BlockTableRecord();
// Open the Block table for read
BlockTable acBlkTbl;
acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId,
OpenMode.ForRead) as BlockTable;
// Create our new block table record...
BlockTableRecord btr = new BlockTableRecord();
// Create a point at (x, y, z) in Model space
DBPoint acPoint = new DBPoint(new Point3d(x, y, 0));
acPoint.SetDatabaseDefaults();
acPoint.Layer = strLayerName;
// Add the new object to the block table record and the transaction
btr.AppendEntity(acPoint);
acTrans.AddNewlyCreatedDBObject(acPoint, true);
// Create a circle with a radius
Circle r = new Circle();
r.SetDatabaseDefaults();
r.Center = new Point3d(x, y, 0);
r.Radius = fltRadius;
r.Layer = strLayerName;
// Add the new object to the block table record and the transaction
btr.AppendEntity(r);
acTrans.AddNewlyCreatedDBObject(r, true);
// Open the Block table record Model space for write
BlockTableRecord acBlkTblRec;
acBlkTblRec = acTrans.GetObject(acBlkTbl,OpenMode.ForWrite) as BlockTableRecord;
BlockReference br = new BlockReference(Point3d.Origin, btrId);
br.Layer = strLayerName;
acBlkTblRec.AppendEntity(br);
acTrans.AddNewlyCreatedDBObject(br, true);
// Commit the transaction to save the new object to the database
acTrans.Commit();
希望这对其他人也有帮助。
干杯,Max。
页:
1
[2]