Sample Code Revit Batch Processor 1.1.15 documentation

Contents:

This Page

duHast.Revit.ExtensibleSchemas package

Submodules

duHast.Revit.ExtensibleSchemas.data_storage module

This module contains a number of functions around data storage in Revit.

Data storage can be used to project wide settings not associated with a specific element.

Obsolete in Revit 2025 …

duHast.Revit.ExtensibleSchemas.data_storage.find_data_storage(doc, schema_guid)

Find a DataStorage element in the Revit document that contains the specified schema.

Parameters:
  • doc (Autodesk.Revit.DB.Document) – The Revit document to search in.

  • schema_guid (str) – The GUID of the schema to look for.

Returns:

The DataStorage element if found, None otherwise.

Return type:

Autodesk.Revit.DB.DataStorage or None

duHast.Revit.ExtensibleSchemas.data_storage.update_entity_on_data_storage(doc, data_storage, entity)

Update the entity of a DataStorage element with new data.

Parameters:
  • 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.

Returns:

A Result object containing the updated DataStorage element in its result list or an error message.

Return type:

duHast.Utilities.Objects.result.Result

duHast.Revit.ExtensibleSchemas.data_storage_create module

This module contains a number of functions around data storage in Revit.

Data storage can be used to project wide settings not associated with a specific element.

Obsolete in Revit 2025 …

duHast.Revit.ExtensibleSchemas.data_storage_create.create_project_data_storage(doc, schema)

Create a new DataStorage element in the Revit document and set its schema.

Parameters:
  • 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.

Returns:

A Result object containing the created DataStorage element in its result list or an error message.

Return type:

duHast.Utilities.Objects.result.Result

duHast.Revit.ExtensibleSchemas.extensible_schema_delete module

This module contains a number of functions around Extensible storage deletion in Revit.

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.

duHast.Revit.ExtensibleSchemas.extensible_schema_delete.delete_schema_by_guid(doc, guid, transaction_manager=<function in_transaction>)

Deletes a schema by its guid. This will also delete all entities that are using this schema.

Note:

Parameters:
  • 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.

Returns:

A Result object with the result of the operation

Return type:

Result

duHast.Revit.ExtensibleSchemas.extensible_schemas module

This module contains a number of functions around Extensible storage in Revit.

duHast.Revit.ExtensibleSchemas.extensible_schemas.does_schema_exist(schema_guid)

Check if a schema exists in the memory.

Parameters:

schema_guid (str) – The guid of the schema to check

Returns:

True if the schema exists, False otherwise

Return type:

bool

duHast.Revit.ExtensibleSchemas.extensible_schemas.get_schema(schema_guid)

Get a schema by its guid.

Parameters:

schema_guid (str) – The guid of the schema to get

Returns:

The schema if it exists, None otherwise

Return type:

Autodesk.Revit.DB.ExtensibleStorage.Schema

duHast.Revit.ExtensibleSchemas.extensible_schemas_create module

This module contains a number of functions around Extensible storage in Revit.

duHast.Revit.ExtensibleSchemas.extensible_schemas_create.create_schema(schema_name, schema_documentation, string_guid, vendor_id='DUHA', access_level_read=Autodesk.Revit.DB.ExtensibleStorage.AccessLevel.Public, access_level_write=Autodesk.Revit.DB.ExtensibleStorage.AccessLevel.Public, field_builder=None)

Basic schema creation sample (excludes any fields). Creates a scheme or returns the already existing scheme with the same guid.

Parameters:
  • 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_write:

Access level to schema for write operations. Default is Public

Access_level_write:

Autodesk.Revit.DB.ExtensibleStorage.AccessLevel

Returns:

The newly created schema, or existing schema with same guid.

Return type:

Autodesk.Revit.DB.ExtensibleStorage.Schema

duHast.Revit.ExtensibleSchemas.extensible_schemas_create.verify_schema_data_storage_based(doc, schema_name, schema_docs, schema_guid, access_level_read=Autodesk.Revit.DB.ExtensibleStorage.AccessLevel.Public, access_level_write=Autodesk.Revit.DB.ExtensibleStorage.AccessLevel.Public, vendor_id='DUHA', field_builder=None)

Verify if the schema exists in the file. if not it will attempt to create it and add to data storage element.

Returns:

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

Return type:

Result

Module contents