怎么用c# 为实体创建缩放区域,双击实体会弹出这个对话框。cad 机械般amtitle 绘制的标题栏图框,怎么用c# 修改缩放比例?
你这个是cad呀,有命令直接调比例
可以使用CAD的API来实现对实体的缩放和修改缩放比例。具体步骤如下:
Document doc = Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
PromptEntityOptions peo = new PromptEntityOptions("\n请选择需要缩放的实体:");
peo.AllowNone = false;
peo.SetRejectMessage("\n只能选择实体,请重新选择:");
peo.AddAllowedClass(typeof(Entity), true);
PromptEntityResult per = ed.GetEntity(peo);
if (per.Status != PromptStatus.OK) return;
Entity ent = (Entity)tr.GetObject(per.ObjectId, OpenMode.ForRead);
double curScale = ent.GetScaleFactors().X;
double newScale = curScale * 2; // 例如将缩放比例扩大2倍
ent.UpgradeOpen();
ent.ScaleFactors = new Scale3d(newScale);
ent.DowngradeOpen();
DocumentLock loc = doc.LockDocument();
try
{
using (Transaction tr = doc.TransactionManager.StartTransaction())
{
Viewport vp = ed.CurrentViewport;
PromptPointOptions ppo = new PromptPointOptions("\n请指定缩放区域的第一个角点:");
PromptPointResult ppr = ed.GetPoint(ppo);
if (ppr.Status != PromptStatus.OK) return;
Point3d pt1 = ppr.Value;
ppo.Message = "\n请指定缩放区域的第二个角点:";
ppo.UseBasePoint = true;
ppo.BasePoint = pt1;
ppr = ed.GetPoint(ppo);
if (ppr.Status != PromptStatus.OK) return;
Point3d pt2 = ppr.Value;
Extents3d ext = new Extents3d(pt1, pt2);
vp.ZoomExtents(ext);
tr.Commit();
}
}
finally
{
doc.UnlockDocument(loc);
}
注意事项:
用 amtitle 绘制的标题栏图框,用c# 获取图框块参照后,修改缩放比例,但是点击弹框中缩放比例不会变。