绘制方柱-JIG应用
本帖最后由 wang2006zhi 于 2024-8-6 13:07 编辑/// <summary>
/// 绘制方柱
/// </summary>
[CommandMethod("W_HZFZ")]
public static void ColuDraw()
{
if (!Env.Editor.GetPoint(out Point3d point1, "选择方柱的第一个角点"))
return;
var pt1 = point1.Ucs2Wcs();
using var tr = new DBTrans();
var layerId = InfoDicLayer[ETypeName.砼柱].MakeLayer();
var txtTypeId = MakeEntity.MakeTxtStyle();
var pline = new Polyline();
pline.SetDatabaseDefaults();
pline.AddVertexAt(0, pt1.Point2d(), 0, 0, 0);
pline.AddVertexAt(1, pt1.Point2d(), 0, 0, 0);
pline.AddVertexAt(2, pt1.Point2d(), 0, 0, 0);
pline.AddVertexAt(3, pt1.Point2d(), 0, 0, 0);
pline.Closed = true;
pline.ConstantWidth = 5;
pline.LayerId = layerId;
var dbtextTempX = new DBText();
dbtextTempX.SetDatabaseDefaults();
dbtextTempX.Height = AppX.InfoSysValue.基本字高 * AppX.InfoSysValue.制图系数 * 0.5;
dbtextTempX.WidthFactor = 0.6;
dbtextTempX.TextStyleId = txtTypeId;
dbtextTempX.LayerId = layerId;
var pt2 = new Point2d();
using var jig1 = new JigEx((mpw, _) =>
{
var vec = mpw - pt1;
var vecXn = vec.Convert2d().GetNormal();
var length = vec.Length.ToRound(InfoSysValue.方柱模数);
pt2 = pt1.Point2d() + length * vecXn;
pline.SetPointAt(1,pt2);
dbtextTempX.TextString = length.ToString("F3");
dbtextTempX.Position = pt1 + 0.5 * vec;
dbtextTempX.Rotation = vecXn.Angle.AngleFormat();
});
jig1.DatabaseEntityDraw(wd =>
{
wd.Geometry.Draw(pline);
wd.Geometry.Draw(dbtextTempX);
});
jig1.SetOptions(pt1,msg: "\n选择方柱的第二个点");
var ppr1 = Env.Editor.Drag(jig1);
if (ppr1.Status != PromptStatus.OK)
return;
var dbtextTempY = new DBText();
dbtextTempY.SetDatabaseDefaults();
dbtextTempY.Height = AppX.InfoSysValue.基本字高 * AppX.InfoSysValue.制图系数 * 0.5;
dbtextTempY.WidthFactor = 0.6;
dbtextTempY.TextStyleId = txtTypeId;
dbtextTempY.LayerId = layerId;
using var jig2 = new JigEx((mpw, _) =>
{
var ptFoot = mpw.GetFootPoint(pt1,pt2.Point3d());
var vec = mpw - ptFoot;
var vecYn = vec.Convert2d().GetNormal();
var length = vec.Length.ToRound(InfoSysValue.方柱模数);
pline.SetPointAt(2, pt2 + length*vecYn);
pline.SetPointAt(3, pt1.Point2d() + length*vecYn);
dbtextTempY.TextString = length.ToString("F3");
dbtextTempY.Position = pt1 + 0.5 * vec;
dbtextTempY.Rotation = vecYn.Angle.AngleFormat();
});
jig2.DatabaseEntityDraw(wd =>
{
wd.Geometry.Draw(pline);
wd.Geometry.Draw(dbtextTempY);
});
jig2.SetOptions(pt2.Point3d(), msg: "\n选择方柱的第三个点");
var ppr2 = Env.Editor.Drag(jig2);
if (ppr2.Status != PromptStatus.OK)
return;
tr.CurrentSpace.AddEntity(pline);
页:
[1]