Schemas

I have created my very first schema in Python. :snake:

No idea how to use it yet… but I created it.

@jacob.small Thanks for the suggestion. :smiley:

image

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!"

image

Test after creation

1 Like

@Alien ,

what does it mean you can create your own unique identity for your elements ?

KR

Andreas

Storage in Revit…
So you can store a load of data that you can allow the user to change… or you can make it so only your app can change it.

I’m currently wading through this and trying to put it into Python
https://adndevblog.typepad.com/aec/2012/07/a-beginners-overview-to-extensible-storage-api.html

So far I’ve made the Schema and added a field builder. :crazy_face:

@Alien ,

is this similar to https://directus.io/ ?

where you can monitor your projects regarding data ?

Don’t think so…
Extensible Storage is storage IN your Revit model.

@Alien ,

i have to see practical use :wink: the article is more than 12 years old… :slight_smile:

ok like metadata thats not visible in the “forground”

Well for me I wanna store loads of data that my users can’t delete;
“I deleted it cos I dunno what it is”…
:rofl:

Also @Draxl_Andreas it’s been in Revit for a decade and you’ve never heard of it… (neither had I)

But still as relevant as ever. :wink:

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:

  1. 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.

  2. 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.

1 Like