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

Subject: Create Grid.
Summary: 
This sample shows how to create grids and modify grids’ properties through Revit API.

Classes: 
Autodesk.Revit.UI.IExternalCommand
Autodesk.Revit.DB

Project Files: 
Command.cs
It contains the class Command which inherits from interface IExternalCommand and implements the Execute method.

CreateGridsData
Base class of grid creation data classes which contains common data and operations.

GridCreationOptionData.cs
Data class which stores the information of the way to create grids.

GridCreationOptionForm.cs
It contains a dialog which lets user choose the way to create grids.

CreateWithSeletedCurvesData.cs
Data class which stores the information for creating grids with selected lines/arcs.

CreateWithSelectedCurvesForm.cs
It contains a dialog which provides the options of creating grids with selected lines/arcs.

CreateOrthogonalGridsData.cs
Data class which stores information for creating orthogonal grids.

CreateOrthogonalGridsForm.cs
It contains a dialog which provides the options of creating orthogonal grids.

CreateRadialAndArcGridsData.cs
Data class which stores information for creating radial and arc grids.

CreateRadialAndArcGridsForm.cs
It contains a dialog which provides the options of creating radial and arc grids.

Unit.cs
It defines a static class Unit to convert unit from display unit type to Revit API’s internal unit.

EnumsAndValues.cs
This file contains two Enumerations and one class.
-	CreateMode enumeration lists the ways to create grids.
-	BubbleLocation enumeration lists bubble locations of grids.
-	Class Values contains common const values used in transforming between degrees and radians.

Validation.cs
This file contains static functions to validate input data before creating grids.

Description: 
This sample provides following functionalities.
-	Let user create grids on the base of the selected lines/arcs.
-	Let user generate orthogonal linear grids with specified origin, spacing of X and Y directions, numbers of X and Y direction grids. 
-	Let user generate radial and arc grids with specified center, span of grids, spacing between concentric arcs and number of rays in the specified span. Even the user can specify radius of the first arc grid and distance from center to the start points of radial grids. 
-	Let user set the label for the first grid like A or 1 and set the location of the bubble for grids to be created.
-	The length units within UI should accord with current project unit setting.

Instructions: 
Open Revit application and execute the command.
1.	Create grids with selected lines/arcs.
a.   Select some lines/arcs in current project.
b.   Execute the command.
c.   Check the option “Create grids with selected lines or arcs”.
d.	In the next “Create Grids with Selected Lines/Arcs” dialog specify the values and click button “Create Grids”.
Expected result: Grids are created on the base of selected lines/arcs. If an arc is a circle, two girds will be created separately for the upper and lower parts of the circle.

2.	Create orthogonal grids.
a.	Execute the command.
b.	Check the option “Create a batch of orthogonal grids”.
c.	In the next “Create Orthogonal Grids” dialog specify the values and click button “Create Grids”.
Expected result: Orthogonal grids are created according to specified values.

3.	Create radial and arc grids.
a.	Execute the command.
b.	Check the option “Create a batch of radial and arc grids”.
c.	In the next “Create Radial and Arc Grids” dialog specify the values and click button “Create Grids”.
Expected result: Radial and arc grids are created according to specified values.