cad文字宽度因子_CAD调整属性块中文字宽度

更新时间:2023-08-03 12:32:49 阅读: 评论:0

cad⽂字宽度因⼦_CAD调整属性块中⽂字宽度using System;
using Autodesk.AutoCAD.ApplicationServices;
落红不是无情物using Autodesk.AutoCAD.DatabaServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Runtime;
[asmbly: CommandClass(typeof(AttributeWidthFactor.MyCommands))]
namespace AttributeWidthFactor
{
public class MyCommands
{
[CommandMethod("AttWidth")]
public static void SetAttrWidthFactor()
曾军良{托业报名
Document dwg = Application.DocumentManager.MdiActiveDocument;
Editor ed = dwg.Editor;
//Pick an attributereference in a block
PromptNestedEntityOptions opt = new
PromptNestedEntityOptions("\nPick an attribute:");
PromptNestedEntityResult res = ed.GetNestedEntity(opt);
if (res.Status == PromptStatus.OK)
{
if (res.ObjectId.ObjectClass.DxfName.ToUpper() == "ATTRIB")
{
//Ask ur to pick a distance as desired width for
//the attribute to fit in. Bad on the block, the width
//could be a known value
PromptPointOptions popt = new
PromptPointOptions("\nPick width ba point:");
PromptPointResult pres = ed.GetPoint(popt);
if (pres.Status != PromptStatus.OK) return;
Point3d baPt = pres.Value;
PromptDistanceOptions dopt =
new PromptDistanceOptions("\nPick width: ");
dopt.UBaPoint = true;
dopt.BaPoint = baPt;
PromptDoubleResult dres = ed.GetDistance(dopt);
if (dres.Status != PromptStatus.OK) return;
//This is the width we want to fit the attribute text's width double w = dres.Value;
购的组词using (Transaction tran =
华为网关
dwg.TransactionManager.StartTransaction())画家笔下的色彩
{
AttributeReference att = (AttributeReference)tran.GetObject( res.ObjectId, OpenMode.ForWrite);
//Get attribute's width, assuming it is placed horizontally double aw = Math.Abs(att.GeometricExtents.MaxPoint.X
- att.GeometricExtents.MinPoint.X);
//This is the WidthFactor
double factor = w / aw;
att.WidthFactor = factor;
tran.Commit();
}
}
el
{
Application.ShowAlertDialog("Not an attribute!");
}
}
}
}
个性签名
}买毛线

本文发布于:2023-08-03 12:32:49,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/89/1106554.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:色彩   调整   落红   报名
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图