# Delete schema - Revit 23 error

**URL:** <https://forum.dynamobim.com/t/delete-schema-revit-23-error/103819>\
**Category:** Developers\
**Created:** [August 23, 2024, 3:46pm UTC](https://forum.dynamobim.com/t/delete-schema-revit-23-error/103819 "2024-08-23T15:46:50Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alien](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alien/32/40701_2.png) [@Alien](https://forum.dynamobim.com/u/Alien)\
**Post date:** [August 23, 2024, 3:46pm UTC](https://forum.dynamobim.com/t/delete-schema-revit-23-error/103819/1 "2024-08-23T15:46:50Z")

</div>

Using the code here as a base: [Purge schemas](https://forum.dynamobim.com/t/purge-schemas/94626)

And it’s here: [EraseSchemaAndAllEntities Method](https://www.revitapidocs.com/2023/50debcb0-3c4f-b32b-2edb-8a6ef7b4bf8d.htm)

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/4/e453f6c68062ea355dbc221a8aee2a141febfa7d.png)

I’ve got this: But it won’t let me delete

What am I doing wrong?

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/c/4/c47d7d714d81ca7a5005157d743bfb6d6852af10.png)

---

<div class="post-metadata">

**Author:** ![Joe.Charpentier](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/joe.charpentier/32/49617_2.png) [@Joe.Charpentier](https://forum.dynamobim.com/u/Joe.Charpentier)\
**Post date:** [August 23, 2024, 3:57pm UTC](https://forum.dynamobim.com/t/delete-schema-revit-23-error/103819/2 "2024-08-23T15:57:26Z")

</div>

I’m no Python expert, but what is the difference between the original example:

```auto
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB.ExtensibleStorage import Schema

```

and what you have:

```auto
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.ExtensibleStorage import *

```

???  
I’d think \* means import everything, but maybe you need to be specific?  
But if \* means “import all methods”, why would you even need  
from Autodesk.Revit.DB.ExtensibleStorage import \*  
After you have  
from Autodesk.Revit.DB import \*

It seems redundant to me, but I have always just built on other people’s scripts that have this sort of thing already. Maybe someone has a good reference on how this works for non-programmers (like me)?

Maybe I just haven’t looked in the Dynamo Primer…

---

<div class="post-metadata">

**Author:** ![Alien](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alien/32/40701_2.png) [@Alien](https://forum.dynamobim.com/u/Alien)\
**Post date:** [August 23, 2024, 4:07pm UTC](https://forum.dynamobim.com/t/delete-schema-revit-23-error/103819/3 "2024-08-23T16:07:36Z")

</div>

Cos it doesn’t automatically import all the nested stuff.

---

<div class="post-metadata">

**Author:** ![Joe.Charpentier](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/joe.charpentier/32/49617_2.png) [@Joe.Charpentier](https://forum.dynamobim.com/u/Joe.Charpentier)\
**Post date:** [August 23, 2024, 4:13pm UTC](https://forum.dynamobim.com/t/delete-schema-revit-23-error/103819/4 "2024-08-23T16:13:50Z")

</div>

Ah, thanks. So since “Schema” is directly under "Extensible storage, you get that when you use the star.

So, I looked more at Revit API docs. It seems that “EraseSchemaAndAllEntities” no longer is used in 2023?  
If you go to the Schema Member page itself:

> **[Schema Members](https://www.revitapidocs.com/2022/a90c962a-f9ae-475f-b66c-49dc57771aee.htm)**
>
> Online Documentation for Autodesk's Revit API: 2015, 2016, 2017, 2017.1, 2018

It says the method is now obsolete in 2023.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/c/bc0bea901dd8da366e3ebef5662e1598f9f58d2a.png)

I have no idea what it was replaced with. I have no idea why the page for the method itself doesn’t state this.

---

<div class="post-metadata">

**Author:** ![Alien](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alien/32/40701_2.png) [@Alien](https://forum.dynamobim.com/u/Alien)\
**Post date:** [August 23, 2024, 4:15pm UTC](https://forum.dynamobim.com/t/delete-schema-revit-23-error/103819/5 "2024-08-23T16:15:54Z")

</div>

Yes… but there are two links to it.

See the link in my original post.

As far as I can see it looks identical… Hence the confusion.

---

<div class="post-metadata">

**Author:** ![Joe.Charpentier](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/joe.charpentier/32/49617_2.png) [@Joe.Charpentier](https://forum.dynamobim.com/u/Joe.Charpentier)\
**Post date:** [August 23, 2024, 4:19pm UTC](https://forum.dynamobim.com/t/delete-schema-revit-23-error/103819/6 "2024-08-23T16:19:49Z")

</div>

Looks like you may be out of luck in 2023. Not sure if it is an actual bug, or something that was done to prevent document corruption:

> **[2024 + EraseSchemaAndAllEntities does not delete the Schema. Unable to delete...](https://forums.autodesk.com/t5/revit-api-forum/2024-eraseschemaandallentities-does-not-delete-the-schema-unable/m-p/12839617)**
>
> Hi,   I have a persistent issue where i am unable to delete old trailling Schema that had a bug in it. The Schema had a conflict with another Schema and i tried to resolve the issue by deleting both of them. I am able to delete the corresponding...

---

<div class="post-metadata">

**Author:** ![Alien](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alien/32/40701_2.png) [@Alien](https://forum.dynamobim.com/u/Alien)\
**Post date:** [August 23, 2024, 4:22pm UTC](https://forum.dynamobim.com/t/delete-schema-revit-23-error/103819/7 "2024-08-23T16:22:53Z")

</div>

Meh, you could be right… Altho 2023 is only mentioned once in that thread…

/me goes to buy booze instead of doing Dynamo. 🍺

---

<div class="post-metadata">

**Author:** ![Joe.Charpentier](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/joe.charpentier/32/49617_2.png) [@Joe.Charpentier](https://forum.dynamobim.com/u/Joe.Charpentier)\
**Post date:** [August 23, 2024, 4:23pm UTC](https://forum.dynamobim.com/t/delete-schema-revit-23-error/103819/8 "2024-08-23T16:23:27Z")

</div>

Hopefully it is Friday afternoon on your planet!

---

<div class="post-metadata">

**Author:** ![Alien](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alien/32/40701_2.png) [@Alien](https://forum.dynamobim.com/u/Alien)\
**Post date:** [August 23, 2024, 4:27pm UTC](https://forum.dynamobim.com/t/delete-schema-revit-23-error/103819/9 "2024-08-23T16:27:53Z")

</div>

It is, AND I get three days where my computer is being upgraded by the alien IT people so I can’t do anything work related…

Whooo!!

---

<div class="post-metadata">

**Author:** ![Joe.Charpentier](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/joe.charpentier/32/49617_2.png) [@Joe.Charpentier](https://forum.dynamobim.com/u/Joe.Charpentier)\
**Post date:** [August 23, 2024, 4:51pm UTC](https://forum.dynamobim.com/t/delete-schema-revit-23-error/103819/10 "2024-08-23T16:51:43Z")

</div>

Seems like there has been some background turmoil under the hood with extensible storage schemas…  
[https://mybimteam.com/kb/how-do-you-fix-revit-schema-errors/](https://mybimteam.com/kb/how-do-you-fix-revit-schema-errors/)

> **[2024.1 Update causes new Schema errors](https://forums.autodesk.com/t5/revit-architecture-forum/2024-1-update-causes-new-schema-errors/m-p/12133961)**
>
> There's been a lot of chatter about the Schema error that was landing in a post about What's New in 2024.1 so I took the good suggestion from   to start a new thread here. What is a Schema? I welcome other people's input on this, but from my...

You are in 2023, this is 2024, but who knows why they removed the method…

---

<div class="post-metadata">

**Author:** ![Alien](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alien/32/40701_2.png) [@Alien](https://forum.dynamobim.com/u/Alien)\
**Post date:** [August 23, 2024, 4:57pm UTC](https://forum.dynamobim.com/t/delete-schema-revit-23-error/103819/11 "2024-08-23T16:57:30Z")

</div>

👾

---

<div class="post-metadata">

**Author:** ![c.poupin](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/c.poupin/32/89152_2.png) [@c.poupin](https://forum.dynamobim.com/u/c.poupin)\
**Post date:** [August 23, 2024, 6:46pm UTC](https://forum.dynamobim.com/t/delete-schema-revit-23-error/103819/12 "2024-08-23T18:46:49Z")

</div>

since Revit 2022 the right method is

`doc.EraseSchemaAndAllEntities(schema)`

the old method

> **[EraseSchemaAndAllEntities Method](https://www.revitapidocs.com/2022/80983aac-0cca-c211-1c7b-b5350624f046.htm)**
>
> Online Documentation for Autodesk's Revit API: 2015, 2016, 2017, 2017.1, 2018

the new one

> **[EraseSchemaAndAllEntities Method](https://www.revitapidocs.com/2023/50debcb0-3c4f-b32b-2edb-8a6ef7b4bf8d.htm)**
>
> Online Documentation for Autodesk's Revit API: 2015, 2016, 2017, 2017.1, 2018

however this won’t solve the problem with Revit 2024, so it’s better to re-create a new schema with a new GUID

---

<div class="post-metadata">

**Author:** ![Alien](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alien/32/40701_2.png) [@Alien](https://forum.dynamobim.com/u/Alien)\
**Post date:** [August 23, 2024, 6:52pm UTC](https://forum.dynamobim.com/t/delete-schema-revit-23-error/103819/13 "2024-08-23T18:52:13Z")

</div>

I’m in Revit 2023.  
I can’t try it till Tuesday now though! But thank you in advance 🙂

---

<div class="post-metadata">

**Author:** ![Alien](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alien/32/40701_2.png) [@Alien](https://forum.dynamobim.com/u/Alien)\
**Post date:** [August 23, 2024, 6:57pm UTC](https://forum.dynamobim.com/t/delete-schema-revit-23-error/103819/14 "2024-08-23T18:57:34Z")

</div>

I have a question; you say you’ve got to write **doc**.Erase…

How do you know this? I can’t see it anywhere in the API.

The only difference I can see is the old one asks for a bool and the new one doesn’t. How would I work this out?

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [August 23, 2024, 7:02pm UTC](https://forum.dynamobim.com/t/delete-schema-revit-23-error/103819/15 "2024-08-23T19:02:08Z")

</div>

> [@Alien](#):
>
> How do you know this?

First is a method (has stuff in the parenthesis) on the Schema class.

Second is a method on the Document class.

---

<div class="post-metadata">

**Author:** ![Alien](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alien/32/40701_2.png) [@Alien](https://forum.dynamobim.com/u/Alien)\
**Post date:** [August 23, 2024, 7:04pm UTC](https://forum.dynamobim.com/t/delete-schema-revit-23-error/103819/16 "2024-08-23T19:04:33Z")

</div>

Ahhhh!!! Thanks 🙂
