Reputation: 135
I am working on a project where I need to create a roof through code in a revit document. I have gone through the following links:
But all of the above links suggest selecting the walls first. Can I create a roof without creating the walls?
Any help would be appreciated.
Thankyou
Upvotes: 0
Views: 652
Reputation: 8314
Sure. You can use the NewFootPrintRoof
method and feed it with a CurveArray to define the footprint.
The external command Lab2_0_CreateLittleHouse
in Labs2.cs in the AdnRevitApiLabsXtra sample code demonstrates how:
corners[0] -= w * ( XYZ.BasisX + XYZ.BasisY );
corners[1] += w * ( XYZ.BasisX - XYZ.BasisY );
corners[2] += w * ( XYZ.BasisX + XYZ.BasisY );
corners[3] -= w * ( XYZ.BasisX - XYZ.BasisY );
CurveArray profile = new CurveArray();
for( int i = 0; i < 4; ++i )
{
Line line = Line.CreateBound( // 2014
corners[i], corners[3 == i ? 0 : i + 1] );
profile.Append( line );
}
List<Element> roofTypes
= new List<Element>(
LabUtils.GetElementsOfType(
doc, typeof( RoofType ),
BuiltInCategory.OST_Roofs ) );
RoofType roofType = roofTypes
.Cast<RoofType>()
.FirstOrDefault<RoofType>( typ
=> null != typ.GetCompoundStructure() );
ModelCurveArray modelCurves
= new ModelCurveArray();
FootPrintRoof roof
= createDoc.NewFootPrintRoof( profile,
levelTop, roofType, out modelCurves );
Upvotes: 0