Extensible storage + Undo

Extensible storage + Undo

jorge.bslu
Advocate Advocate
586 Views
5 Replies
Message 1 of 6

Extensible storage + Undo

jorge.bslu
Advocate
Advocate

Hi,

For sure, I am probably doing something wrong, but I am facing the following issue with Revit 2023 & 2024:

  • Start Revit and create a new project
  • Start a transaction (actually a transaction group since I am exporting a physical+analytical model to Revit)
  • Create schema (mySchema)
  • Export a steel beam (1) and other analytical stuffs
  • Set entity to that family instance with that schema
  • End transaction
  • Everything looks fine

Next:

  • Start transaction 2 in the same document
  • schema = Schema.Lookup(sameIdThanBefore)
  • Call document.EraseSchemaAndAllEntities(schema)
  • Export another steel beam (2)
  • Set entity to it with "schema"
  • End transaction
  • I see that beam 2 has its entity but not beam 1 (as I'd expect)

Then, I click "undo" in Revit UI:

  • Steel beam 2 has disappeared (as expected) because all stuffs from transaction group 2 has gone
  • Entity for beam 1 has disappeared as well. I would expect to see the entity from the first transaction. 
  • It looks like document.EraseSchemaAndAllEntities is not undoable 🤔?

Any clue on this issue. I have taken a look at the different posts and Jeremmy's blog but I did not find anything that could help me.

Regards

0 Likes
Accepted solutions (2)
587 Views
5 Replies
Replies (5)
Message 2 of 6

jeremy_tammik
Alumni
Alumni
Accepted solution

This sounds pretty suspect to me. Please consider an extensile storage schema something that you create once and for all for all eternity. You never modify it in any way whatsoever. You can delete it, but I would be careful with that as well. This has caused many complications and misunderstandings, so best to consider it undeletable as well. If you wish, go ahead and delete the data entities. Just leave the schema alone. Can you reformulate your question based on such considerations? Thank you!

  

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

jorge.bslu
Advocate
Advocate

Hi @jeremy_tammik ,

Thanks for taking your time to reply.

I get it. I don't want (nor need) to delete any schema since they are singleton objects in memory (nothing more sensitive than then), but what I want is "to wipe" entities from Revit elements before a new exportation to Revit is performed.

Maybe, I need to implement my own method (instead of calling doc.EraseSchemaAndAllEntities) to remove just the entities from elements. I hope that loop does not make negative impact on performance.

I will give it a try and hope that fixes my issue.

I'll keep you posted.

 

0 Likes
Message 4 of 6

jeremy_tammik
Alumni
Alumni

My pleasure, thank you for your appreciation. Sounds like a good approach to me. Good luck and hope it works as expected then.

  

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

jorge.bslu
Advocate
Advocate
Accepted solution

My first tests are working fine by just deleting the entities without calling revitDocument.EraseSchemaAndAllEntities.

I am wondering if a revitDocument.EraseAllEntities(schema) method in the API could be added to the wish list 😬

In any case, thank you very much for your help !!

Message 6 of 6

jeremy_tammik
Alumni
Alumni

I'm very glad that it helped. Thank you for your appreciation. I see no great need for such a method, given that you can quickly filter for elements equipped with a certain extensible storage schema data entity using a ExtensibleStorageFilter and then process those as needed.

  

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