Deleting and Updating Extensible Storage Schema

We discussed a number of extensible storage schema topics in the past.

Once you’ve started using it, you may run into the need to update or delete something.

Discussing that also provides an opportunity to summarise the other results we already have:

Deleting an Extensible Storage Schema

Question: I am unable to delete my extensible storage schema if the RVT project contains a linked project with the same schema.

First I thought I was doing something wrong, but the ExtensibleStorageUtility SDK sample project DeleteStorage command has the same problem.

Answer: Please be aware that all extensible storage schemata are held in memory and shared between all open projects in the current Revit session.

Therefore, if any of the currently open projects is making use of a specific schema, that will prevent it from being deleted.

I hope this is clear and explains the behaviour you are observing.

Updating an Extensible Storage Schema

Question: I need to add some additional fields to an existing extensible storage schema.
How can I achieve this?

Right now, I am deleting the schema and creating a new one with all the required fields.

My current workaround to delete successfully is to unload the Revit links before deleting the schema.

Another solution I have been considering is to just leave the existing schema and create a new one. That seems a bit messy, though, so I have avoided that so far.

What is the best practice if you have an existing extensible storage scheme and you want to add more fields to it?
A far as I can see, it is impossible to change existing schema fields.

Answer: Yes, indeed, schema fields cannot be modified, nor can new fields be added.

Once you publish a schema it is there, immutable, for the rest of the life of the universe.

If you wish to add new fields or modify existing ones, you have to create a new schema.

The old one remains untouched.

You can easily implement an update handler in your add-in that automatically updates all instances of the old schema that it encounters to the new one.

This is demonstrated by the UpgradeSchema sample provided by my extensible storage

class
and

lab
at
Autodesk University 2011, which include the complete background information on the topic.

The full

handouts and sample material
are
also available directly from The Building Coder.

Some additional topics that we covered since then include:

Response: I might change my mind on my current solution unloading and loading Revit links to be able to delete the schema, because it might still not solve problem in all cases.
For instance, if users have two Revit projects open and both use the schema, I guess it will not work. All projects have the schema, because I add it on project open.

Answer: Yes, I think you can and certainly sooner or later will run into problems modifying an existing schema.

Creating a new one is the only safe way to go.


Comments

10 responses to “Deleting and Updating Extensible Storage Schema”

  1. Dear Jeremy
    Do you know if it is possible to store created Schemas onto a material and have that persist through a material library? I would like be to able to add some extra data onto a material and then be able to bring in those materials with the extra data on them through the material library.
    I am a bit new to Revit so I’m sure that I’m missing something.
    Thanks,
    Alan

  2. Dear Alan,
    Thank you for a pertinent and interesting question.
    A material library is unfortunately not a Revit document, so it does not contain Revit database elements, so it cannot include extensible storage in the same manner.
    You would have to find some other way to associate your additional data with the desired material.
    You might have a Revit ‘material project’ somewhere, and interact with that.
    Here is a vaguely related discussion on managing materials that might be of interest and useful for this question:
    http://thebuildingcoder.typepad.com/blog/2013/05/copy-and-paste-api-applications-and-modeless-assertion.html#4
    Please let us know if you implement a generic solution to this. That would be very interesting. Thank you!
    Cheers, Jeremy.

  3. Dear Jermey,
    Thanks for the clarification, we had already looked into having a Revit material project which we did get working and it did work very well. We just wanted to avoid having extra work involved with pulling in materials, since we always want them available.
    We decided to simply add an id to one of the parameters like the Comments field and look for the id somewhere in there.
    Thanks again,
    Alan

  4. Matt Brown Avatar
    Matt Brown

    Dear Jeremy,
    I have a problem with a few of our Revit files where the error “The file … modified by the third-party updater AREXRevitStart : REXExtension: DReinfWall which is not currently installed.” appears. I would like to use code to find references to this extension and delete it. However, when I call Schema.ListSchemas() there are no schemas returned. How is it that the file is still using the extensible storage from the third-party updater? I have no linked Revit files but I still run into this issue.
    Thanks,
    Matt

  5. Dear Matt,
    ListSchemas will not return anything, because it only lists loaded schemata. The error message is telling you that this schema is referenced but not loaded, probably because the add-in that defined and stored a reference to it in the model no longer is present.
    All you have to do to get rid of this is to open the model once, click ‘ignore and continue’, and then save it again:
    http://thebuildingcoder.typepad.com/blog/2010/12/vsta-to-stay-and-updater-to-go.html#2
    I do not know of any other way to get rid of the message.
    It should be possible to automate this process, though:
    http://thebuildingcoder.typepad.com/blog/2010/12/vsta-to-stay-and-updater-to-go.html#3
    Cheers, Jeremy.

  6. Dear Jeremy,
    I’m using the revit element GUID to create the schema. Now that I want to update this schema (Create a new one), I can not use anymore this GUID, i get this kind of message: A different Schema with the same identity already exists.
    Do you have any suggestion for my update? Can i get rid of the old schema before creating the new one? I need to use this GUID to create the new schema.
    Cheers,

  7. Dear Jimmy,
    That’s a nice pickle you’ve gotten yourself into.
    A GUID that must have a certain value cannot really be called a GUID, you know.
    So you have set up a system in which the Revit element UniqueID is used a a key to determine a hard-wired GUID value for your extensible storage data.
    That does not sound like a very good idea to me.
    It is utterly impossible to modify the extensible storage schema in any way whatsoever, as far as I know:
    http://thebuildingcoder.typepad.com/blog/2013/08/deleting-and-updating-extensible-storage-schema.html
    So, just as you say, you will have to define an entirely new schema, and transfer the existing data you wish to preserve from the old to the new.
    If you are forced to specify the same key, you will definitely have to delete the old schema before you can create the new one.
    Whether or not Revit will allow you to create a new schema using the same GUID as the old one had I cannot say.
    I can imagine that there might be difficulties with that.
    In any case, you will have to completely remove every trace of the old before trying to define the new.
    Good luck with that, and please let us know how it goes.
    Cheers, Jeremy.

  8. I found this: EraseSchemaAndAllEntities! Save my addin!
    Cheers

  9. Just see your answer Jeremy, thanks for the reply!
    So as I said, I did an upgrader that loop over all my “old” schemas, save temporally the data, erase all the “old” schemas with EraseSchemaAndAllEntities, then create the new schema.
    People will have to upgrade their revit file before continue using the addin.
    Thanks again!

  10. Dear Jimmy,
    Congratulations on solving the issue.
    I am glad to hear that it is possible to redefine a schema reusing its original GUID once it has been completely removed.
    I was previously not aware of that.
    Merry Christmas and a Happy New Year to you!
    Cheers, Jeremy.

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading