Correct way of deleting Schemas in 2025?

Correct way of deleting Schemas in 2025?

philip_adlergard
Contributor Contributor
233 Views
2 Replies
Message 1 of 3

Correct way of deleting Schemas in 2025?

philip_adlergard
Contributor
Contributor

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

  

0 Likes
234 Views
2 Replies
Replies (2)
Message 2 of 3

jeremy_tammik
Alumni
Alumni

What version of Revit 2025 are you running? I would suggest installing the most recent update, in case you have not already done so. I think various improvements were introduced during the release cycle.

   

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 3 of 3

philip_adlergard
Contributor
Contributor

It's written that in realease of 2025 the improvement is done to make it possible to delete. I'm using 2025.3, so it should be working?

0 Likes