- 积分
- 6140
- 明经币
- 个
- 注册时间
- 2016-10-12
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
本帖最后由 wang2006zhi 于 2025-6-20 10:26 编辑
 - /// <summary>
- /// 结构详图配筋标注
- /// </summary>
- [CommandMethod("W_XTBZ")]
- public static void DimXiangTu()
- {
- if (!Env.Editor.GetPoint(out var getPt, "请点取一个点:"))
- return;
- var infoSysValue = AppX.InfoSysValue;//获取默认参数
- var ct = infoSysValue.出图系数;
- var txtHight = 250;
- var strTxtUp = "上部文字";
- var strTxtDown = "下部文字";
- using var tr = new DBTrans();//开启事务
- var infoDicLayer = infoSysValue.设计模型.GetInfoDicLayer();//获取图层字典
- var txtLayerId = infoDicLayer[ETypeName.文字].MakeLayer();//创建文字标柱图层
- var txtTypeId = MakeEntity.EnumTextStyle.Norm.MakeTxtStyle();//创建文字样式
- var pline = new Polyline();//创建PL线
- pline.SetDatabaseDefaults();
- pline.AddVertexAt(0, getPt.Point2d(), 0, 0, 0);
- pline.AddVertexAt(1, getPt.Point2d(), 0, 0, 0);
- pline.AddVertexAt(2, getPt.Point2d(), 0, 0, 0);
- pline.Closed = false;
- pline.LayerId = txtLayerId;
- var textUp = new DBText();//创建文字Up
- textUp.SetDatabaseDefaults();
- textUp.TextStyleId = txtTypeId;
- textUp.LayerId = txtLayerId;
- textUp.TextString = strTxtUp;
- textUp.Height = txtHight * ct;
- textUp.WidthFactor = 0.7;
- textUp.HorizontalMode = TextHorizontalMode.TextLeft;
- var textUpWidth = textUp.GetRecAng().Rec.Width;
- var textDown = new DBText();
- textDown.SetDatabaseDefaults();
- textDown.TextStyleId = txtTypeId;
- textDown.LayerId = txtLayerId;
- textDown.TextString = strTxtDown;
- textDown.Height = txtHight * ct;
- textDown.WidthFactor = 0.7;
- textDown.HorizontalMode = TextHorizontalMode.TextLeft;
- var textDownWidth = textDown.GetRecAng().Rec.Width;
- var dWidthMax = Math.Max(textUpWidth, textDownWidth);
- var vecX = new Vector3d(1, 0, 0);
- var vecY = new Vector3d(0, 1, 0);
- using var jig = new JigEx((mpw, _) =>
- {
- var vec = mpw - getPt;
- textUp.Position = mpw + vecY * textUp.Height * 0.05;
- textDown.Position = mpw - vecY * textUp.Height * 1.05;
- var ptEnd = mpw + vecX * dWidthMax;
- var drag = vec.DotProduct(vecX);
- if (drag < 0)
- {
- ptEnd = mpw - vecX * dWidthMax;
- textUp.Position = ptEnd + vecY * textUp.Height * 0.05;
- textDown.Position = ptEnd - vecY * textUp.Height * 1.05;
- }
- pline.SetPointAt(1, mpw.Point2d());
- pline.SetPointAt(2, ptEnd.Point2d());
- });
- jig.DatabaseEntityDraw(wd =>
- {
- wd.Geometry.Draw(pline);
- wd.Geometry.Draw(textUp);
- wd.Geometry.Draw(textDown);
- });
- jig.SetOptions("指定放入点:");
- while (true)
- {
- var pr = Env.Editor.Drag(jig);
- if (pr.Status != PromptStatus.OK)
- return;
- if (strTxtDown.IsNullOrWhiteSpace())
- tr.CurrentSpace.AddEntity(pline, textUp);
- else
- tr.CurrentSpace.AddEntity(pline, textUp, textDown);
- return;
- }
- }
|
|