Message 1 of 3
Correct way of deleting Schemas in 2025?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I've created some test schemas that I want to remove now. I've tried both the doc.EraseSchemaAndAllEntites and element.DeleteEntity as below. I'm doing it in transaction but nothing works.
I read that it is an old bug that should be fixex, but how to do it?
var collector = new FilteredElementCollector(doc);
var walls2 = collector.OfClass(typeof(Wall)).ToElements();
var schema = Schema.ListSchemas().FirstOrDefault(s => s.SchemaName.Equals("UpdaterData", StringComparison.OrdinalIgnoreCase));
using(var transaction = new Transaction(doc, "Delete old schema"))
{
transaction.Start();
foreach (var wall in walls2)
{
var entity = wall.GetEntity(schema);
if (entity.IsValid())
{
wall.DeleteEntity(schema);
}
}
transaction.Commit();
}
var boaBtaExists = DoesSchemaExist("UpdaterData"); // Here it still exists. And even in RevitLookup