forked from KennanChan/RevitAPIToolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestSchema.cs
37 lines (34 loc) · 1.25 KB
/
TestSchema.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System.Web.Script.Serialization;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Techyard.Revit.Attributes;
using Techyard.Revit.Database;
using Techyard.Revit.Misc.SchemaDesigner;
using Techyard.Revit.UI;
namespace Test
{
[Transaction(TransactionMode.Manual)]
public class TestSchema : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
var uiDocument = commandData.Application.ActiveUIDocument;
var document = uiDocument.Document;
var element = uiDocument.Selection.SelectSingle(document);
var mySchema = new CustomSchema { Editor = "Kennan", Age = 26 };
element.WriteData(mySchema);
var value = element.ReadData(new CustomSchema());
TaskDialog.Show("Value", new JavaScriptSerializer().Serialize(value));
return Result.Succeeded;
}
}
[Schema(Name = "MySchema", Guid = "09A33462-4979-49F0-A15E-90DFE444C243")]
public class CustomSchema : SchemaBase
{
[SchemaField(Name = "Editor")]
public string Editor { get; set; }
[SchemaField(Name = "Age")]
public int Age { get; set; }
}
}