这里记录一下项目上遇到的问题,就是创建带洞口的墙的时候,会发现创建接口仅有一个线集合传进去(如下图)。当墙体有洞口的时候,线段就只能再一个集合中传进去了。
这时候会遇到一点问题,就是直接把两个轮廓的线传进去,会出现无法创建墙体的错误(如下图)
经过一段时间的研究,发现,只要所有的轮廓首尾相连,然后轮廓线的方向都一致,即顺时针或者逆时针,就可以生成墙体了。
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
UIDocument uidoc = commandData.Application.ActiveUIDocument;
Document doc = uidoc.Document;
List<Curve> wallBoundaryList = GetWallBoundaryList();
Transaction trans = new Transaction(doc, "创建墙体");
trans.Start();
Wall.Create(doc, wallBoundaryList, false);
trans.Commit();
return Result.Succeeded;
}
public List<Curve> GetWallBoundaryList()
{
List<Curve> result = new List<Curve>();
XYZ p1 = new XYZ(0, 0, 0);
XYZ p2 = new XYZ(10, 0, 0);
XYZ p3 = new XYZ(10, 0, 10);
XYZ p4 = new XYZ(0, 0, 10);
XYZ p5 = new XYZ(3, 0, 3);
XYZ p6 = new XYZ(7, 0, 3);
XYZ p7 = new XYZ(7, 0, 7);
XYZ p8 = new XYZ(3, 0, 7);
Line l1 = Line.CreateBound(p1, p2);
Line l2 = Line.CreateBound(p2, p3);
Line l3 = Line.CreateBound(p3, p4);
Line l4 = Line.CreateBound(p4, p1);
Line l5 = Line.CreateBound(p5, p6);
Line l6 = Line.CreateBound(p6, p7);
Line l7 = Line.CreateBound(p7, p8);
Line l8 = Line.CreateBound(p8, p5);
result = new List<Curve>()
{
l1,
l2,
l3,
l4,
l5,
l6,
l7,
l8,
};
return result;
}
这次分享的是创建带洞口墙的方法。希望对你有帮助~~~
#21.10.14 记录新研究的几个点,有可能影响墙体的创建
1、轮廓线的第一根线不能和最后一根线平行。
2、内轮廓的第一根线不能和外轮廓的第一根线垂直
满足这两个条件,基本带轮廓的墙都可以生成。