- 积分
- 5816
- 明经币
- 个
- 注册时间
- 2016-10-12
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
本帖最后由 wang2006zhi 于 2024-8-13 21:16 编辑
/// <summary>
/// 绘制墙体
/// </summary>
[CommandMethod("W_HZQT")]
[AttributeEx.MenuInfo("通用符号", "绘制墙体", 5, 10)]
public static void WallDraw()
{
var offsetDist = AppX.InfoSysValue.墙体宽度;
Env.Editor.WriteMessage($"\n当前墙体厚度:{offsetDist}");
if (!Env.Editor.GetPoint(out Point3d point1, "选择第一个点"))
return;
using var tr = new DBTrans();
var layerId = InfoDicLayer[ETypeName.墙线].MakeLayer();
var plineTemp = new Polyline();
plineTemp.AddVertexAt(0, point1.Point2d(), 0, 0, 0);
plineTemp.AddVertexAt(1, point1.Point2d(), 0, 0, 0);
using var jig = new JigEx((mpw, _) =>
{
plineTemp.SetPointAt(plineTemp.NumberOfVertices - 1, mpw.Point2d());
});
jig.DatabaseEntityDraw(wd => wd.Geometry.Draw(plineTemp));
var jppo = jig.SetOptions(plineTemp.GetPoint3dAt(plineTemp.NumberOfVertices - 1), CursorType.Crosshair,
"\n选择下一点");
jppo.Keywords.Add("U", "U", "撤回(U)");
while (true)
{
jppo.BasePoint = plineTemp.GetPoint3dAt(plineTemp.NumberOfVertices - 1);
var r2 = Env.Editor.Drag(jig);
if (r2.Status == PromptStatus.OK)
plineTemp.AddVertexAt(plineTemp.NumberOfVertices, jig.MousePointWcsLast.Point2d(), 0, 0, 0);
else if (r2.Status == PromptStatus.Keyword)
{
switch (r2.StringResult.ToUpper())
{
case "U":
if (plineTemp.NumberOfVertices > 2)
{
plineTemp.RemoveVertexAt(plineTemp.NumberOfVertices - 2);
}
break;
}
}
else
{
if (plineTemp.NumberOfVertices > 2)
{
plineTemp.RemoveVertexAt(plineTemp.NumberOfVertices - 1);
break;
}
}
}
var pts = plineTemp.GetPoints();
var pt2 = plineTemp.EndPoint;
pts.AddRange(pts);
var newpl = pts.CreatePolyline();
newpl.Closed = true;
newpl.LayerId = layerId;
using var jig2 = new JigEx((mpw, _) =>
{
var pt = plineTemp.EndPoint;
if (offsetDist >= 600)
offsetDist = 600;
if (mpw.X < pt.X)
offsetDist = -offsetDist;
Doubpline(plineTemp, offsetDist, newpl);
});
jig2.DatabaseEntityDraw(wd => { wd.Geometry.Draw(newpl); });
jig2.SetOptions(pt2, msg: "\n 选择第一个点");
var ppr3 = Env.Editor.Drag(jig2);
if (ppr3.Status != PromptStatus.OK)
return;
tr.CurrentSpace.AddEntity(newpl);
void Doubpline(Polyline pl, double dou, Polyline polyline)
{
var num = pl.NumberOfVertices;
if (pl.GetOffsetCurves(dou)[0] is Polyline newpl1)
{
var npts = newpl1.GetPoints();
npts.Reverse();
for (int i = npts.Count - 1; i >= 0; i--)
{
polyline.SetPointAt(num + i, npts.Point2d());
}
}
}
}
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注册
x
|