对容器类调用deepclone有点奇怪,呵呵- [CommandMethod("t10")]
- public static void Test10()
- {
- Document doc = Application.DocumentManager.MdiActiveDocument;
- Database db = doc.Database;
- using (var tr = db.TransactionManager.StartTransaction())
- {
- var bt = tr.GetObject(db.BlockTableId, OpenMode.ForWrite) as BlockTable;
- var blkdef = tr.GetObject(bt["1"], OpenMode.ForRead) as BlockTableRecord;
- var blkdefnew = new BlockTableRecord();
- blkdefnew.Name = "2";
- var id = bt.Add(blkdefnew);
- tr.AddNewlyCreatedDBObject(blkdefnew, true);
- var ids = new ObjectIdCollection(blkdef.Cast<ObjectId>().ToArray());
- db.DeepCloneObjects(ids, id, new IdMapping(), true);
- var ents =
- blkdefnew.Cast<ObjectId>()
- .Select(i => tr.GetObject(i, OpenMode.ForWrite) as Entity);
- foreach (var ent in ents)
- ent.ColorIndex = 2;
- tr.Commit();
- }
- }
|