Sample Code Revit Batch Processor 1.1.15 documentation
Data storage can be used to project wide settings not associated with a specific element.
Obsolete in Revit 2025 …
Find a DataStorage element in the Revit document that contains the specified schema.
doc (Autodesk.Revit.DB.Document) – The Revit document to search in.
schema_guid (str) – The GUID of the schema to look for.
The DataStorage element if found, None otherwise.
Autodesk.Revit.DB.DataStorage or None
Update the entity of a DataStorage element with new data.
doc (Autodesk.Revit.DB.Document) – The Revit document to update the DataStorage element in.
data_storage (Autodesk.Revit.DB.DataStorage) – The DataStorage element to update.
entity (Autodesk.Revit.DB.ExtensibleStorage.Entity) – The new entity to set on the DataStorage element.
A Result object containing the updated DataStorage element in its result list or an error message.
Data storage can be used to project wide settings not associated with a specific element.
Obsolete in Revit 2025 …
Create a new DataStorage element in the Revit document and set its schema.
doc (Autodesk.Revit.DB.Document) – The Revit document to create the DataStorage element in.
schema (Autodesk.Revit.DB.ExtensibleStorage.Schema) – The schema to set on the DataStorage element.
A Result object containing the created DataStorage element in its result list or an error message.
Notes from the building coder website: https://thebuildingcoder.typepad.com/blog/2022/11/extensible-storage-schema-deletion.html
The devteam replied: After running DeleteSchemas macro, open Manage > Purge Unused. In the tree, select Extensible Storage Schema. Check the schema a9dc2b48 and click OK to purge it. Run ListSchemas – the schema is purged. So, please use Purge Unused to delete schemas without entities.
Extensible storage schema is an application-wide object. If it exists at all in the application, it will populate and “infect” every single document that you touch. That makes it hard to remove, and complicated to understand.
Personally I found:
The schema is not removed from the document when you delete it. You have to purge it manually.
If the schema exists in a link and you delete it, it will not go away … unload any links or replace any links with dummy links without the schema and attempt to delete and purge again.
Deletes a schema by its guid. This will also delete all entities that are using this schema.
Note:
doc (Autodesk.Revit.DB.Document) – The Revit document
guid (str) – The guid of the schema to delete
transaction_manager (function) – The transaction manager to use. Defaults to in_transaction.
A Result object with the result of the operation
Check if a schema exists in the memory.
schema_guid (str) – The guid of the schema to check
True if the schema exists, False otherwise
bool
Get a schema by its guid.
schema_guid (str) – The guid of the schema to get
The schema if it exists, None otherwise
Autodesk.Revit.DB.ExtensibleStorage.Schema
Basic schema creation sample (excludes any fields). Creates a scheme or returns the already existing scheme with the same guid.
schema_name (str) – The name of the schema
schema_documentation (str) – A short description of the schema
string_guid (str) – A guid. (unique identifier of this schema)
access_level_read (Autodesk.Revit.DB.ExtensibleStorage.AccessLevel) – Access level to schema for read operations. Default is Public.
Access level to schema for write operations. Default is Public
Autodesk.Revit.DB.ExtensibleStorage.AccessLevel
The newly created schema, or existing schema with same guid.
Autodesk.Revit.DB.ExtensibleStorage.Schema
Verify if the schema exists in the file. if not it will attempt to create it and add to data storage element.
Result class instance.
result.status. True if schema was verified or created successfully, otherwise False.
result.message will contain messages status messages.
result.result tuple (schema,data_storage)
On exception:
result.status (bool) will be False.
result.message will contain generic exception message.
result.result will be empty