Extensible Storage with dynamo python

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


error:
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.

2 Likes

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
t.Commit()

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)