出处
翻译
在Revit .NET API 2013,尽管NewWall方法已移动到Wall类本身,但屋顶生成方法尚未移动。它仍在文件中。创建实例。不管怎样,我们找到了它的位置,并能够建造一些屋顶。
在本文中,让我们创建一个规则多边形屋顶。以下是核心帮助方法。
public static RoofBase CreateRegularPolygonalRoof(
Document doc, Level level, RoofType rooftype,
XYZ location, double radius, int sides,
double slopeangle, double offset)
{
CurveArray profile = new CurveArray();
for (int i = 0; i < sides; i++)
{
double curAngle = i * Math.PI / sides * 2;
double nextAngle = (i < sides - 1 ? i + 1 : 0) * Math.PI / sides * 2;
XYZ curVertex = new XYZ(location.X + radius * Math.Cos(curAngle), location.Y + radius * Math.Sin(curAngle), location.Z);
XYZ nextVertex = new XYZ(location.X + radius * Math.Cos(nextAngle), location.Y + radius * Math.Sin(nextAngle), location.Z);
Line line = doc.Application.Create.NewLineBound(curVertex, nextVertex);
profile.Append(line);
}
ModelCurveArray curveArrayMapping = new ModelCurveArray();
FootPrintRoof roof = doc.Create.NewFootPrintRoof(profile, level, rooftype, out curveArrayMapping);
foreach (ModelCurve curve in curveArrayMapping)
{
roof.set_DefinesSlope(curve, true);
roof.set_SlopeAngle(curve, slopeangle);
roof.set_Offset(curve, offset);
}
return roof;
}
以下是一些示例调用代码:
RoofCreation.CreateRegularPolygonalRoof(
CachedDoc,
RoofCreation.FindAndSortLevels(CachedDoc).First(),
RoofCreation.FindRoofTypes(CachedDoc).First(),
XYZ.Zero,
10.0,
8,
Math.PI / 6,
0.0);
这是Revit中的一个规则多边形屋顶: