Extensible Storage with dynamo python

How to create Extensible Storage with different type of fields and write it to family using dynamo?

Traceback (most recent call last):
File “”, line 26, in
TypeError: expected Type, got str

You are passing a string constructor rather than a Type as your argument. However, you may have to make this a .NET type, not a Python type. As remarked in the API documentation:

The supported types are Boolean, Byte, Int16, Int32, Float, Double, ElementId, GUID, String, XYZ, UV and Entity.

So, change line 5 to this:
from System import Guid, String

and change line 26 to this:
fbStoredId = schemaBuilder.AddSimpleField("StoredId", String)

Apart from this, I don’t have a full solution as I have not worked with extensible storage.


Thank you for reply. But it not working. Now I have next error:
Traceback (most recent call last):
File “”, line 38, in
TypeError: expected Guid, got builtin_function_or_method

Finish() is a method of the SchemaBuilder class, therefore the open and closed parentheses are necessary. If you change line 37 to this, it should work:

schema = schemaBuilder.Finish()

1 Like

Very big thanks!!! Its worked!!! :hugs:
Tell me please: how to delete this Schema?
I try do it with Schema.EraseSchemaAndAllEntities(sch, Boolean(True))
and result: error

Traceback (most recent call last):
File “”, line 48, in
Exception: An internal error has occurred.

How i can use System variable (Bool for Example) and how to delete Schema?

I don’t think line 47 is necessary. In regards to my previous reply, you may be able to use str (without parentheses) as opposed to System.String, but I can’t test this myself. I don’t think the Boolean struct in C# has any public constructors, but you can just use the Python bool instead (True). So, try deleting line 47 and replacing line 48 with this:

Schema.EraseSchemaAndAllEntities(sch, True)

It is typically not necessary to cast primitive data types when using them in Python with the Revit API. For example, a string:

element.LookupParameter('Parameter Name')

or an integer:

element_id = ElementId(123456)

Note that you don’t have to convert 'Parameter Name' to a System.String object or 123456 to a System.Int32 object. Similarly, you can use the Python bool True in your case without having to do anything extra.

Now I have next error:
What wrong???

Traceback (most recent call last):
File “”, line 113, in
File “”, line 53, in StorageDelete
Exception: An internal error has occurred.

I solved the problem. For delete Extensible Storage I have to unload all linked files first and run the method Schema.EraseSchemaAndAllEntities(schema, False), and after
Schema.EraseSchemaAndAllEntities(schema, True)
Finaly code for delete Extensible Storage:

SchGs = type(None)
SchGs= el.GetEntitySchemaGuids()
for SchG in SchGs:
sch = Schema.Lookup(SchG)
schname= sch.SchemaName
if schname == schemaName:
t= Transaction(doc)
t.Start(“Delete Storage”)
Schema.EraseSchemaAndAllEntities(sch, False)
Schema.EraseSchemaAndAllEntities(sch, True) #delete schema

After creating Extesible Storage the fields of my values is empty.
Method .AddSimpleField create fields wery well. But after i can’t write something there

That specific syntax isn’t valid in Python. Although I can’t test it myself, I would try removing <String> and <Int16>.

Very big thanks!!! It worked:
ent.Set(MyFieldNameString, MyStringValue)

Hello, i am too trying to work with extensible storage, got stuck to set the value to the element, it would be helpful if you can share a full python script file for set a new entity and to delete Extensible Storage.

how to store point in field?
schemabuilder.AddSimpleField (“Mypoint”, XYZ) not working. Dynamo say something about field units.
Iam add SetUnitType(UnitType.UT_Lenght) - not working
iam add SetUnitType(UnitType.UT_Undefined) - not working

@a.koltakovADRC7 is it possible to share what you have acchieved till now. i understand from what you have done till now how to creat a schema and assign it to the elements. but reading, updating and deleting the data is not clear to me yet. i think it would be useful if that become clear in this topic. I wonder also when the extensible storage can influence the performance of your model?
about the point i think the second field is data type so i would try to use String then when i need to use it as a point i will convert it (point.ToXyz())

1 Like

thank you so much it is very useful… can see a lots of research done to reach the point… really appreciate.

By the way, I don’t think you can add fields to the schema. She is “baked” during creation (SchemaBuilder.Finish). At least I was unable to add fields. Easier to delete the schema and re-create it with new fields

You are welcome. If you want to write some Ext stror Schemas, i think the best way is to make it with some steps. In my case dynamo script usaly suspend Revit app during writing two schemas in one pass. I manage to write several schemas Ext stror in Revit model without problems only in C #.
A common problem in Ext.Stor creation is an attempt to create a schema with a GUID already in the model. In this case, you should delete the schema completely or create it with a different GUID (to generate a new GUID, I use https://www.guidgenerator.com/).
I have encountered difficulties in creating Ext Stor several times due to linked models. Reconnecting the links usually fixes the problem.

Hi there,

Thanks for this posts on the extensible storage. Got it to work in Revit 2018 (we’re lagging behind at our firm…) with the example codes by a.koltakovADRC7. Thanks!

However… now trying to accomplish the same in Revit 2021… Not so much of luck… If I use code below to create a schema and attach it to the project info, somehow the value does not get stored. Schema is created, field is created…


# Enable Python support and load DesignScript library
import clr
import Revit
from System import Guid, String, Boolean, Int16, Int32
from Autodesk.DesignScript.Geometry import *
from Autodesk.Revit.DB import *
from Autodesk.Revit.Attributes import *
from Autodesk.Revit.DB.ExtensibleStorage import *
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
dataEnteringNode = IN

elem = UnwrapElement(IN[0][0])
schemaName = IN[1]
acces = UnwrapElement(IN[2])
myGuid = IN[3]
type1 = elem.GetTypeId()
asString = type1.ToString()

schemaBuilder = SchemaBuilder(Guid (myGuid))
schemaBuilder.SetSchemaName (schemaName)
fbStoredfield1 = schemaBuilder.AddSimpleField("Max_prefab_beton_wall_number", String)
schema = schemaBuilder.Finish()

ent = Entity(schema)
ent.Set ("Max_prefab_beton_wall_number", "Test")

t = Transaction(doc)
t.Start("Create Storage")

# Assign your output to the OUT variable.
OUT = elem

When I snoop the DB it finds the schema and it shows this massage:

Als if I try to retrieve the value in throug Dynamo Python, there is no value…

Can anybody give me a pointer on what’s going wrong? Thanks!