Application: Serialization
REXSDK Version: 2018.0
First Released For: REXSDK 2012
Last Modified: 01/07/2016
Modified By: Autodesk
Programming Language: C#
Skill Level: Easy 

Subject: Demonstrate how to serialize data inside an element and how to read data serialized previously.  

Summary: 
This sample demonstrates how to read input data from UI and serialize them inside a selected element.
On the second run of this extension, this example shows how to read data serialized inside an element. 

REXSDK values: 
-	Read data from UI.
-	Save data to element.
-	Load data from element.

Project Files: 

Generated by the wizard:

Extension.cs:
The main class generated by the wizard. It contains definition of the Extension class which is the main class in the REXExtension module. This class is a central point which allows user to manage and customize the module.

ExtensionRevit.cs:
This file contains an ExtensionRevit class. This class allows to separate general functionality (provided by the Extension class) from functionality characteristic for the Revit context e.g. setting layouts may be done in the Extension class but reading Revit elements should be carried out in the ExtensionRevit class. In this sample OnCreateLayout() and OnRun() have been updated.

Data.cs
This file contains a Data class which is a data container accessible from different places in the module. All common objects should be placed in this class.
On this file are updated methods OnSetDefaults(), OnSave() and OnLoad(). 

Application.cs, DirectAccess.cs, Results.cs
These files were generated by the wizard but there is no need to make any changes in their content.

Subcontrol.cs
	This file contains a SubControl generated by the wizard. This sub control hosts some controls initialized on the constructor. In addition 2 methods have been filled – SetDialog() and SetData().      

Description: 
This sample gives the ability to define 2 numbers, to serialize them inside a selected element and also to read data serialized. 

Instructions: 
1.	Copy the module to the …Modules/Category directory
2.	Open Revit.
3.	Create a beam  
4.	Select the beam 
5.	Run the Extension.
6.	Fill Edit boxes. 
7.	Click Ok. Data define on the UI will be serialized on the selected element.
8.	Select again the element 
9.	Run Extension
10.	Data serialized previously are displayed on the UI.