就像我在之前的帖子中提到的,你用标准比例改变它,并传递一个枚举值
- [CommandMethod("StandardScaleViewPort")]
- public void StandardScaleViewPort()
- {
- Document doc = Application.DocumentManager.MdiActiveDocument;
- Database db = doc.Database;
- Editor ed = doc.Editor;
- using (Transaction trx = db.TransactionManager.StartTransaction())
- {
- PromptEntityOptions peo = new PromptEntityOptions("\nSelect Viewport: ");
- peo.SetRejectMessage("\nInvalid selection...");
- peo.AddAllowedClass(typeof(Viewport), true);
- PromptEntityResult per = ed.GetEntity(peo);
- if (per.Status != PromptStatus.OK)
- {
- return;
- }
- Viewport vp = trx.GetObject(per.ObjectId, OpenMode.ForWrite) as Viewport;
- vp.StandardScale = StandardScaleType.Scale1To8inchAnd1ft
- trx.Commit();
- }
- }
或者使用自定义比例并在双精度中传递,这与第一个命令相同,只是它要求比例并使用customscale属性
- [CommandMethod("CustomScaleViewport")]
- public void CustomScaleViewport()
- {
- Document doc = Application.DocumentManager.MdiActiveDocument;
- Database db = doc.Database;
- Editor ed = doc.Editor;
- using (Transaction trx = db.TransactionManager.StartTransaction())
- {
- PromptEntityOptions peo = new PromptEntityOptions("\nSelect Viewport: ");
- peo.SetRejectMessage("\nInvalid selection...");
- peo.AddAllowedClass(typeof(Viewport), true);
- PromptEntityResult per = ed.GetEntity(peo);
- if (per.Status != PromptStatus.OK)
- {
- return;
- }
- Viewport vp = trx.GetObject(per.ObjectId, OpenMode.ForWrite) as Viewport;
- PromptDoubleOptions pdo = new PromptDoubleOptions("\nEnter Scale");
- PromptDoubleResult pdr = ed.GetDouble(pdo);
- if (pdr.Status != PromptStatus.OK)
- {
- return;
- }
- vp.CustomScale = pdr.Value
- trx.Commit();
- }
- }
|