Application: NewRoof
Revit Platform: All
Revit Version: 2011.0
First Released For: 2009.0
Programming Language: C#
Skill Level: High
Category: Elements
Type: ExternalCommand

Subject: Create footprint and extrusion roof.
Summary: 
This sample demonstrates four main features:
1.	How to create a new footprint roof.
2.	How to create an extrusion roof.
3.	How to edit an existed footprint roof.
4.	How to edit an existed extrusion roof.

Classes: 
Autodesk.Revit.UI.IExternalCommand
Autodesk.Revit.DB.FootPrintRoof
Autodesk.Revit.DB.ExtrusionRoof
Autodesk.Revit.DB.Level
Autodesk.Revit.DB.RoofType
Autodesk.Revit.DB.Wall
Autodesk.Revit.DB.Curve
Autodesk.Revit.Creation.Document

Project Files: 
Command.cs
This file contains the class “Command” which inherits from “IExternalCommand” interface and implements the “Execute” method.

RoofsManager.cs
It contains a class named “RoofsManager” which is used to manage the operation between Revit and the Add-In UI. It have the functionalities to create footprint roof, create extrusion roof, select footprint to create footprint roof and select profile to create extrusion roof in Revit.

FootPrintRoofManager.cs
It contains a class named “FootPrintRoofManager” which is used to manage the creation of footprint roof.

ExtrusionRoofManager.cs
It contains a class named “ExtrusionRoofManager” which is used to manage creation of extrusion roof.

RoofForm.cs
It contains a class named “RoofForm” which is the main UI of the Add-In application. 

RoofEditorForm.cs
It contains a class named “RoofEditorForm” which is the edit UI to edit a selected roof in the RoofForm. It contains a PropertyGrid to allow user modify the properties or parameters of the selected roof.

GraphicsControl.cs
It contains a class named “GraphicsControl” which is used to display the footprint roof lines in a picture box control when the user is editing a footprint roof. The modifying footprint roof line will be highlighted in the control.

CustomTypeConverter.cs
It contains a LevelConverter class and a FootPrintRoofLineConverter class. They are used to custom the display of the some properties in the PropertyGrid control.

FootPrintRoofWrapper.cs
It contains a FootPrintRoofWrapper class and a FootPrintRoofLine class. The FootPrintRoofWrapper class is used to wrapper a footprint roof to edit the roof in a PropertyGrid control. The FootPrintRoofLine is used to edit the footprint roof line in a PropertyGrid and the line can be drawn in GDI.

ExtrusionRoofWrapper.cs
It contains a class named “ExtrusionRoofWrapper” which is used to wrapper an extrusion roof to edit the roof in a PropertyGrid control.

Description: 
Functionalities:
-	Get all footprint roofs and extrusion roofs in active document and list them grouped by the creation way.
-	Create a footprint roof with default properties by specifying a curve loop, or a wall loop, or loops combination of walls and curves, a level and a roof type.
-	Create an extruded roof by providing a profile which is a series of connected lines or arcs, not closed in a loop, a roof type, a reference plane, an extrusion start value and an extrusion end value. Note that the reference plane should be a vertical plane.
-	Select a footprint roof in the list, then user can define a footprint roof line is slope-defining and can change the slope angel of the selected roof, Also other properties of roof line can be changed respectively, such as overhang, offset from base, extend into wall. The roof’s type can be changed just select a different type.
-	Select an extrusion roof in the list, and then user can change the value of extrusion start, extrusion end, and the roof type and the reference level of the extrusion roof.

Implementations:
-	Using Element Filter to get all kinds roofs.
-	Create footprint roof by the FootPrintRoof NewFootPrintRoof(CurveArray footPrint, Level level, RoofType roofType, ElementIdSet footPrintToModelCurvesMapping) method. The footprint can be specified by WindowsSelect() method of Selection class. The roof types can be obtained by the Autodesk.Revit.DB.Document.RoofTypes property.
-	Create extrusion roof by the ExtrusionRoof NewExtrusionRoof(CurveArray profile, ReferencePlane refPlane, Level level, RoofType roofType, double extrusionStart, double extrusionEnd) method. The profile can be specified by WindowsSelect method and the reference plane should be vertical and can be obtained by using Element filtering functionality
-	Edit the footprint roof or extrusion roof by accessing the properties or parameters of the selected roof.

Instructions: 
1.	Open a Revit Architecture 2009 file. A sample project file NewRoof.rvt is available in the sample’s folder.
2.	Draw a curve loop or a wall loop or loops combination of walls and curves to create a footprint roof in Revit. 
3.	Run this command.
4.	A dialog will be shown to display all the existed roofs. The footprint roofs will be listed in the footprint roof tab page and the extrusion roofs will be listed in the extrusion tab page.
5.	In the footprint roof tab page, click “Select footprint in Revit” button to select the footprint you just created. Select a base level and roof type then click the “Create” button; a footprint roof will be created in Revit and will be listed in the footprint roof tab page. Click “OK” button to accept the creation or click the “Cancel” button to abort.
6.	Draw a series of connected lines or arcs, not closed in a loop to create a profile in Revit. Draw a reference plane in Revit for extrude the profile to create an extrusion roof. Make sure the reference plan is vertical or the extrusion roof will be not creating successfully. If there are many reference planes in Revit, you’d better create a good name for each plane to distinguish them.
7.	In the extrusion roof tab page, click “Select profile in Revit” button to select the profile you just created. Select a reference plane, reference level, roof type and specify the extrusion start and extrusion end value, and then click the “Create” button; an extrusion roof will be created in Revit and will be listed in the extrusion roof tab page. For more information of extrusion start and extrusion end, you’d better refer the extrusion roof part of the help document supplied by Revit. Click “OK” button to accept the creation or click the “Cancel” button to abort.
8.	Edit a footprint roof. You can select a footprint roof and click the “Edit” button or you just double click the roof in the in the footprint roof tab page; a roof editor form will be displayed. The properties of the roof you can edit in the PropertyGird. The footprint roof lines will be displayed also; the current selected roof line in PropertyGird will be highlighted in red color. You can modify the roof type in the roof type combo box. After the finish the modification you can click the “OK” button to accept the change or click the “Cancel” button to abort.
9.	Edit an extrusion roof. You can select an extrusion roof and click the “Edit” button or you just double click the roof in the in the extrusion roof tab page; a roof editor form will be displayed. You can edit the parameters of the extrusion roof in the PropertyGird. After the finish the modification you can click the “OK” button to accept the change or click the “Cancel” button to abort.