谢谢杰夫!你是对的。
我创建了不同的实体(例如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[0];
- // 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[1];
- // 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[blockTableRecord.ModelSpace],OpenMode.ForWrite) as BlockTableRecord;
-
- BlockReference br = new BlockReference(Point3d.Origin, btrId);
- br.Layer = strLayerName[0];
- acBlkTblRec.AppendEntity(br);
- acTrans.AddNewlyCreatedDBObject(br, true);
- // Commit the transaction to save the new object to the database
- acTrans.Commit();
希望这对其他人也有帮助。
干杯,Max。 |