public void testMove() { Database db = HostApplicationServices.WorkingDatabase; Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; PromptSelectionOptions optSel = new PromptSelectionOptions(); optSel.MessageForAdding = "请选择对象"; PromptSelectionResult resSel = ed.GetSelection(); if (resSel.Status != PromptStatus.OK) { return; } SelectionSet sset = resSel.Value; ObjectId[] ids = sset.GetObjectIds(); foreach (ObjectId id in ids) { Edit.Move(id, new Point3d(0, 0, 0), new Point3d(300, 200, 0)); } }
public void testOffset() { Database db = HostApplicationServices.WorkingDatabase; Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; PromptEntityOptions optEnt = new PromptEntityOptions("\n请选择要偏移的对象"); PromptEntityResult resEnt = ed.GetEntity(optEnt); if (resEnt.Status == PromptStatus.OK) { using (Transaction trans = db.TransactionManager.StartTransaction()) { try { Curve ent = (Curve)trans.GetObject(resEnt.ObjectId, OpenMode.ForRead); Edit.Offset(ent, -10); } catch { ed.WriteMessage("\n无法偏移!"); } trans.Commit(); } } }