Wipe Data Schema bug

Small/easy fix. But Schemas are a mystery.

In the script for Wipe Data Schema, there is a condition for running EraseSchemaAndAllEntities. If host version is greater than 2020, use the method in Schema. This method only existed in Revit 21. It moved back to doc.EraseSchemaAndAllEntities(sschema) in Revit 22 and beyond.

            if HOST_APP.version > 2020:
                DB.ExtensibleStorage.Schema.EraseSchemaAndAllEntities(
                    schema=sschema,
                    overrideWriteAccessWithUserPermission=True
                )
            else:
                doc.EraseSchemaAndAllEntities(sschema)

Does anyone have experience with ridding a model of old schemas?

Schemas are a pain to completely purge. It seems this method above does not do much in Revit 22 and above. The schemas persist or are recreated if the Addin that created them is loaded, obviously. But they seem to come back no matter what I do.
I am not picking on Ideate here. No problems with their tools. We want to clean our some others that seem to be causing issues.

I have deleted all elements with a bimlink schema Ideate and the bimlink schemas itself.
Purged Extensible Data (the count matched the number of Schemas I wiped.)
Saved, closed, disabled Ideate addin,
Rrestart Revit
The bimlink schema is back. But zero entities with that schema. Maybe this should be enough for me but it would be nice to rid the model of extensible data from addins we don’t use anymore.

Here is my rough pass at deleting elements with a given Schema:

 collector = DB.FilteredElementCollector(doc).WhereElementIsNotElementType()
            print("Found {0} elements in the model".format(collector.GetElementCount()))

            filtered_elements = []
            for element in collector:
                entity = element.GetEntity(sschema)
                if entity.IsValid():
                    filtered_elements.append(element)
            if len(filtered_elements) > 0:
                print("Found {0} elements with schema {1}".format(len(filtered_elements), sschema.SchemaName))
                for element in filtered_elements:
                    print("Element Name/ID,  {0} / {1}, has schema {2}\n\n\n".format(element.Name, element.Id,
                                                                               sschema.SchemaName))
                    element.DeleteEntity(sschema)
                    print("Deleted schema {0} from element {1}\n\n\n".format(sschema.SchemaName, element.Id))

Then I follow up with the original method from pyRevit tools. This seems to function without error. But the Schemas come back!

Hi, and Welcome,
Just a thought
If you are working on a local file that could be due to the synchronization with the central, which would bring back the schema as someone else can have the plugin bringing the schema installed.

1 Like