Application: FamilyParametersOrder
Revit Platform: All
Revit Version: 2015.0
First Released For: 2015.0
Programming Language: C#
Skill Level: Medium
Category: Parameters, Families
Type: ExternalCommand

Subject: Sort family parameters' order.
Summary: 
This sample demonstrates how to sort the family parameters' order. The family could be a disk file or have been loaded into a project.

Classes: 
Autodesk.Revit.DB
Autodesk.Revit.UI.IExternalCommand;
Autodesk.Revit.UI.IExternalApplication;
Autodesk.Revit.DB.FilteredElementCollector;
Autodesk.Revit.DB.Family;
Autodesk.Revit.DB.FamilyManager;
Autodesk.Revit.DB.IFamilyLoadOptions;
Autodesk.Revit.DB.FamilySource;
Autodesk.Revit.DB.Document;
Autodesk.Revit.ApplicationServices.Application;
Project Files: 
Command.cs
This file contains the class Command which inherits from IExternalCommand interface and implements the Execute method.

ExternalApplication.cs
This file contains the class ExternalApplication which inherits from IExternalApplicationinterface and bind the document opened event to pop up a dialog.

SortFamilyFilesParamsForm.cs
This file contains the class SortFamilyFilesParamsForm which will pop up a dialog to sort parameters in family files which are located in a specified folder(not include subfolders).

SortLoadedFamiliesParamsForm.cs
This file contains the class SortLoadedFamiliesParamsForm which will will pop up a dialog to sort parameters' order in families loaded into a document.

Description: 
This sample provides following functionalities.
-	Batch sort parameters' order in family files which are located in a folder.
-	Sort parameters' order in families which is loaded into a project or a family.

Instructions: 
Open Revit application and execute the command.
1.	Batch sort parameters' order in family files which are located in a folder.
a.   Execute the command.
b.   Select a folder contains some family files by “Browse” button, or input the folder(absolute or relative) which contains some family files.
c.   "A–>Z" button will update parameters in each family files located in the specific folder to alphabet order.
d.	"Z–>A" button will update parameters in each family files located in the specific folder to reverse alphabet order.
e.  "Close" button will close the whole dialog.

Expected result: Parameters in family files will be sorted as alphabet order or reversed alphabet order.

2.	Sort parameters' order in families which is loaded into a project or a family.
a.	Open a revit document, a dialog will pop up after the document is opened.
b.	"A–>Z" button will update parameters in each loaded family to alphabet order then reload the family to project.
c.  "Z–>A" button will update parameters in each loaded family to reverse alphabet order then reload the family to project.
d.  "Close" button will close the whole dialog.

Expected result: Parameters in loaded and editable families in the opened document will be sorted alphabet order or reversed alphabet order.