按比例缩放视图
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.ApplicationServices;
namespace AutoDemo7
{
public class Class1
{
//按比例缩放
[CommandMethod("ZoomScale")]
public static void ZoomScale()
{
//创建文档管理 获取当前文档
Document acDoc = Application.DocumentManager.MdiActiveDocument;
//声明数据库
Database acDB = acDoc.Database;
double s;
s = 2;
using (Transaction acTran = acDB.TransactionManager.StartTransaction())
{
ViewTableRecord acView;
acView = acDoc.Editor.GetCurrentView();
double dWidth, dHeight;
dWidth = acView.Width;
dHeight = acView.Height;
acDoc.Editor.WriteMessage("原始图的宽度:" + dWidth.ToString() + "原始图高度:" + dHeight.ToString()+"\n");
acView.Width = dWidth * (1 / s);
acView.Height = dHeight * (1 / s);
acDoc.Editor.SetCurrentView(acView);
acTran.Commit();
acDoc.Editor.WriteMessage("宽度:" + acView.Width.ToString() + "高度:" + acView.Height.ToString());
}
}
}
}