Autodesk.Revit.DB.FreeFormElement是Revit API中的一个类,用于创建自由形状的元素。使用此类可以创建自定义的建筑构件或其他复杂的几何形状。
Autodesk.Revit.DB.FreeFormElement类包含以下成员:
CurveLoops
:一个列表,包含一个或多个闭合的曲线环,表示自由形状的边界。Geometry
:一个包含自由形状的几何体数据的对象。Autodesk.Revit.DB.FreeFormElement类包含以下方法:
GetBoundingBox()
: 返回自由形状的边界框。以下示例代码使用Autodesk.Revit.DB.FreeFormElement创建自定义形状的建筑构件。
// 创建自由形状
CurveLoop curveLoop = new CurveLoop();
curveLoop.Append(Line.CreateBound(new Point(0,0,0), new Point(10,0,0)));
curveLoop.Append(Line.CreateBound(new Point(10,0,0), new Point(10,10,0)));
curveLoop.Append(Line.CreateBound(new Point(10,10,0), new Point(0,10,0)));
curveLoop.Append(Line.CreateBound(new Point(0,10,0), new Point(0,0,0)));
List<CurveLoop> curveLoops = new List<CurveLoop>();
curveLoops.Append(curveLoop);
GeometryElement geometryElement = GeometryCreationUtilities.CreateExtrusionGeometry(new List<CurveLoop>() { curveLoop }, new XYZ(0,0,1), 10);
FreeFormElement freeFormElement = FreeFormElement.Create(document, geometryElement);
// 创建建筑构件
FilteredElementCollector collector = new FilteredElementCollector(document);
Level level = collector.OfClass(typeof(Level)).First(l => l.Name == "Level 1") as Level;
WallType wallType = collector.OfClass(typeof(WallType)).First(w => w.Name == "Generic - 8\"") as WallType;
XYZ startPoint = new XYZ(0,0,0);
XYZ endPoint = new XYZ(10,0,0);
Wall wall = Wall.Create(document, Curve.CreateBound(startPoint, endPoint), level.Id, false);
wall.get_Parameter(BuiltInParameter.WALL_USER_HEIGHT_PARAM).Set(10);
wall.get_Parameter(BuiltInParameter.WALL_BASE_CONSTRAINT).Set(level.Id);
wall.get_Parameter(BuiltInParameter.ELEM_FAMILY_PARAM).Set(wallType.Id);
wall.get_Parameter(BuiltInParameter.ELEM_FAMILY_AND_TYPE_PARAM).Set(wallType.Id);
wall.get_Parameter(BuiltInParameter.WALL_STRUCTURAL_SIGNIFICANT).Set(1);
wall.get_Parameter(BuiltInParameter.WALL_SWEEP_FAMILY_AND_PROFILE).Set(freeFormElement.Id);