- [CommandMethod("PickDemo")]
- public void PickDemo()
- {
- Database db = HostApplicationServices.WorkingDatabase;
- Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
- PromptEntityResult per = ed.GetEntity("选择块");
- if (per.Status == PromptStatus.OK)
- {
- using (Transaction trans = db.TransactionManager.StartTransaction())
- {
- ResultBuffer result = new ResultBuffer();
- BlockTable bt = (BlockTable)trans.GetObject(db.BlockTableId, OpenMode.ForRead);
- BlockReference br = (BlockReference)per.ObjectId.GetObject(OpenMode.ForRead);
- string blkname = br.Name;
- ed.WriteMessage("\nBlock Name: (" + blkname + ").");
- ObjectId blockRecordId = bt[blkname];
- BlockTableRecord blockRecord = (BlockTableRecord)blockRecordId.GetObject(OpenMode.ForRead);
- Extents3d tmpExtents3D = new Extents3d();
- foreach (ObjectId entID in blockRecord)
- {
- Entity entity = (Entity)trans.GetObject(entID, OpenMode.ForRead);
- Extents3d tmp = entity.GeometricExtents;
- tmpExtents3D.AddExtents(tmp);
-
-
- }
- Point3d maxpt = tmpExtents3D.MaxPoint;
- Point3d minpt = tmpExtents3D.MinPoint;
- result.Add(new TypedValue((int)LispDataType.Point3d, minpt));
- result.Add(new TypedValue((int)LispDataType.Point3d, maxpt));
- trans.Commit();
- //return result;
- }
- }
- }
|