public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
UIApplication uiapp = commandData.Application;
UIDocument uidoc = commandData.Application.ActiveUIDocument;
Document doc = uidoc.Document;
Autodesk.Revit.DB.View view = doc.ActiveView;
Reference refer = uidoc.Selection.PickObject(ObjectType.Element, "");
Wall wall = doc.GetElement(refer) as Wall;
Transaction tran = new Transaction(doc, "BIM");
tran.Start();
SchemaBuilder bulder = new SchemaBuilder(new Guid("11111111-bbbb-4444-cccc-333333333333"));
bulder.SetReadAccessLevel(AccessLevel.Public);
bulder.SetWriteAccessLevel(AccessLevel.Public);
bulder.SetSchemaName("WallArray");
bulder.SetDocumentation("Data store for array");
FieldBuilder fiedBuilder = bulder.AddArrayField("array", typeof(string));
Schema schema = bulder.Finish();
Entity ent = new Entity(schema);
Field field = schema.GetField("array");
IList(string) liststring = new List(string)();
liststring.Add("123456");
liststring.Add("abcdef");
ent.Set(IList(string))(field, liststring);
wall.SetEntity(ent);
tran.Commit();
IList(Guid) listGuid = wall.GetEntitySchemaGuids();
Schema sa = Schema.Lookup(listGuid[0]);
Entity entity = wall.GetEntity(sa);
IList(string) diclist = entity.Get(IList(string))(sa.GetField("array"));
for (int i = 0; i < diclist.Count; i++)
{
MessageBox.Show(diclist[i]);
}
return Result.Succeeded;
}