import clr
clr.AddReference('RevitAPI')
clr.AddReference('RevitServices')
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.UI.Selection import ObjectType
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
import System
doc = DocumentManager.Instance.CurrentDBDocument
uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
TransactionManager.Instance.EnsureInTransaction(doc)
wallRef = uidoc.Selection.PickObject(ObjectType.Element, "Select a wall")
wall = doc.GetElement(wallRef.ElementId)
schemaId = System.Guid("USE YOUR OWN GUID :dragon_face:")
schema = ExtensibleStorage.Schema.Lookup(schemaId)
if schema is None:
builder = ExtensibleStorage.SchemaBuilder(schemaId)
builder.SetReadAccessLevel(ExtensibleStorage.AccessLevel.Public)
builder.SetWriteAccessLevel(ExtensibleStorage.AccessLevel.Public)
builder.SetSchemaName("VeryFirstAttemptAtThis")
builder.SetDocumentation("Data store for my very first attempt")
schema = builder.Finish()
output = "Schema created successfully."
else:
output = "Schema already exists."
TransactionManager.Instance.TransactionTaskDone()
OUT = output, "moose!"
Basically extensible storage allows you to put data that doesn’t comply to a typical Revit data type into your model, and work with it as you might need. Two examples:
Imagine you wanted to pack the path of travel produced via VASA to go from Room A on level 3 to Room B on level 1; currently Revit has no default way to store that data, as there is no such thing as a 3d polyline of unknown definition, nor can we make points in a standard environment. But extensible storage allows us to define a schema which packs the point locations into the model. An add-in can then access the data to display a spline in 3D between the points and generate the graphic in your plan/section/whatnot as desired.
Imagine you have to do the plumbing fixture count for a mixed use occupancy in the city of Boston, Massachusetts. You could go and update a key schedule and build out the nightmare list of formulas, or you could pack the formaulas and lookup tables into extensible storage via an add-in, and then use another module of the add-in to calculate the value(s).
The scope of what you can put in here is only limited by what can be serialized into code - I have packed images, .rfa files, .dyn files, and even .exe files in there before.