Upgrade 2024 API causing schema error

Upgrade 2024 API causing schema error

ptranU2KHX
Advocate Advocate
5,630 Views
29 Replies
Message 1 of 30

Upgrade 2024 API causing schema error

ptranU2KHX
Advocate
Advocate

Hi everyone,

Hope you all are doing great.

Recently, I upgraded the revit library with the lastest version 2024.

Since then, I got the error 'different schema with same identity...' although I do not change the schema structure or add new schema with the same id. 

I doubted about the ElementId class as it is one of the changes in the API.

 

Please help. Thank you in advance.

 

ptranU2KHX_0-1683683251464.png

 

Accepted solutions (1)
5,631 Views
29 Replies
Replies (29)
Message 21 of 30

GaryOrrMBI
Collaborator
Collaborator

@moturi.magati.george  

It's great that this issue is being taken seriously and is being worked on.

 

At this point I would like to see if they can open that investigation up a bit further. Since the changes made in 2021 with the method of deleting a schema and it not actually getting erased from memory, then re-inserting itself (several posts on this issue)... Yes, a workaround of manually purging it after deleting it via the UI was put out there but, as far as I know it is still a problem.

 

And, to go one step further...

The concept of extensible storage schemas is to allow storage of information within a document and/or an entity in a document... yet the system was built in such a way that the schema, once created lives in the application's space. This is an underlying and fundamental issue. Storage schemas should exist in the document's space (be created when called within a document, released when changing or closing documents, and not cross the document boundaries).

 

just my 2 cents

 

-G

 

Gary J. Orr
GaryOrrMBI (MBI Companies 2014-Current)
aka (past user names):
Gary_J_Orr (GOMO Stuff 2008-2014);
OrrG (Forum Studio 2005-2008);
Gary J. Orr (LHB Inc 2002-2005);
Orr, Gary J. (Gossen Livingston 1997-2002)
Message 22 of 30

RPTHOMAS108
Mentor
Mentor

Apart from this case every schema conflict that exists only exists because someone somewhere has modified a schema after creating it, it just requires a bit of discipline. I've seen even Autodesk make the mistake on one of their classification add-ins, so it is easy to do I get that. I made the mistake myself a decade ago when it was first introduced but never since, back then it caused Revit to crash.

 

Regarding application space vs document space in reality the document is read into memory so is the schema, do they then have exactly the same structure read for every document that uses it? Lastly this isn't managed memory it is unmanaged and the whole technology behind it (OLE structured storage) was written in the mid 90's. It likely works the way it works to an extent because of this, there is only so much they can do to make it safe and 'user-proof' to a managed environment programmer.

 

One method was removed for 2022

Schema.EraseSchemaAndAllEntities

Now you have

Document.EraseSchemaAndAllEntities

 

I don't know why the first one was removed they probably realised it was a bit misleading because you can't actually remove entities from  ReadOnly documents that exist in the background such as links.

 

If the schema was owned and given write protection by another add-in you would still have the same access problem with either of those methods. I think purging is likely the only real option because then it is an end user decision but it can only be purged if it isn't used but then if it isn't used why is it in memory? Perhaps it can be purged regardless (used or not used) I haven't really looked at that.

 

To Autodesk: I also wonder why DataStorage elements are not protected from deletion i.e. is it the case that it doesn't matter what the write access is you can still delete the DataStorage element? People are not going to move away from adding entities to the project information element until the alternative is protected in the same way (or until it is prevented).

0 Likes
Message 23 of 30

GaryOrrMBI
Collaborator
Collaborator

@RPTHOMAS108 

Perhaps I need to find a way to think and speak in programmer's terms 🙂

What I'm trying to say is that... a door family in project a that is slightly different in project b doesn't cause a conflict if the projects are linked together and/or open in the same session. A storage entity should be the same way, live entirely where it is placed.

 

I agree completely that changes to a schema shouldn't be changed (how are you going to know what information you're pulling if you keep changing the information that you're storing...)

 

But, removing a schema should be as simple as it was before they changed the method. The old method worked to fix a mistake or otherwise clean up after yourself... the newer method doesn't.

 

Not a single Architect/Designer/Engineer that works at my firm has a clue what a storage entity is or if/when they should be purged, yet 100% of our documents have them from one app or another, including the ones that I build for our management requirements.

 

I guess I just don't see the difference, only that the old Erase... used to work cleanly and completely and now the new version doesn't.

 

But anyway, back to work.

Have a wonderful weekend

-G

Gary J. Orr
GaryOrrMBI (MBI Companies 2014-Current)
aka (past user names):
Gary_J_Orr (GOMO Stuff 2008-2014);
OrrG (Forum Studio 2005-2008);
Gary J. Orr (LHB Inc 2002-2005);
Orr, Gary J. (Gossen Livingston 1997-2002)
0 Likes
Message 24 of 30

ken_marsh_pelogic
Contributor
Contributor

Hi, we've run into this same issue and also suspect an issue with the ElementID upgrade in ES.  Is there any update from the product team?

Thanks!

0 Likes
Message 25 of 30

ptranU2KHX
Advocate
Advocate

Hi @ken_marsh_pelogic 

 

According to the Revit preview release, it seems this issue will be resolved.

Please refer to this site: https://help-beta.autodesk.com/view/RVT/2025/ENU/?guid=RevitPreviewReleaseNotes_release_notes_Resolv...

0 Likes
Message 26 of 30

ken_marsh_pelogic
Contributor
Contributor

Revit 2024 hotfix 2024.1 appears to fix this issue for schemas which contain "ElementID" data types.

 

Refer to the release notes for 2024.1, resolved issues highlights this issue of upgrading schemas with ElementID fields.

Message 27 of 30

pfk
Enthusiast
Enthusiast

Hi - I have also been having this issue.  I just installed Revit 2024.1 and the issue persists.  Whenever I load a .RVT file saved with Revit 2023 into Revit 2024.1, I get an exception (attached).

 

Revit Version info....

24.1.0.66
20230701_1515(x64)
2024.1.0

 

Code....

                    SchemaBuilder schemaBuilder = new SchemaBuilder(new Guid("A5A1FFF5-7A3A-42CF-8769-0796B05685EA"));
                    schemaBuilder.SetReadAccessLevel(AccessLevel.Public);
                    schemaBuilder.SetWriteAccessLevel(AccessLevel.Public);
                    schemaBuilder.SetSchemaName("OctaneProxyItem");

                    FieldBuilder fieldBuilder = schemaBuilder.AddSimpleField("m_ObjFilename", typeof(string));
                    fieldBuilder = schemaBuilder.AddSimpleField("m_CsvFilename", typeof(string));
                    fieldBuilder = schemaBuilder.AddSimpleField("m_ScaleAllAxis", typeof(bool));
                    fieldBuilder = schemaBuilder.AddSimpleField("m_Scale", typeof(double));
                    fieldBuilder.SetSpec(SpecTypeId.Length);
                    fieldBuilder = schemaBuilder.AddSimpleField("m_XScale", typeof(double));
                    fieldBuilder.SetSpec(SpecTypeId.Length);
                    fieldBuilder = schemaBuilder.AddSimpleField("m_YScale", typeof(double));
                    fieldBuilder.SetSpec(SpecTypeId.Length);
                    fieldBuilder = schemaBuilder.AddSimpleField("m_ZScale", typeof(double));
                    fieldBuilder.SetSpec(SpecTypeId.Length);
                    fieldBuilder = schemaBuilder.AddSimpleField("m_XRotation", typeof(double));
                    fieldBuilder.SetSpec(SpecTypeId.Length);
                    fieldBuilder = schemaBuilder.AddSimpleField("m_YRotation", typeof(double));
                    fieldBuilder.SetSpec(SpecTypeId.Length);
                    fieldBuilder = schemaBuilder.AddSimpleField("m_ZRotation", typeof(double));
                    fieldBuilder.SetSpec(SpecTypeId.Length);
                    fieldBuilder = schemaBuilder.AddSimpleField("m_ElementId", typeof(ElementId));

                    // Scatter generation fields - not curerntly used
                    fieldBuilder = schemaBuilder.AddSimpleField("m_NumTransforms", typeof(int));
                    fieldBuilder = schemaBuilder.AddSimpleField("m_MeshElementId", typeof(ElementId));
                    fieldBuilder = schemaBuilder.AddSimpleField("m_NumRows", typeof(int));
                    fieldBuilder = schemaBuilder.AddSimpleField("m_NumCols", typeof(int));
                    fieldBuilder = schemaBuilder.AddSimpleField("m_FollowMeshNormals", typeof(bool));
                    fieldBuilder = schemaBuilder.AddSimpleField("m_RotationRandomnessX", typeof(double));
                    fieldBuilder.SetSpec(SpecTypeId.Length);
                    fieldBuilder = schemaBuilder.AddSimpleField("m_RotationRandomnessY", typeof(double));
                    fieldBuilder.SetSpec(SpecTypeId.Length);
                    fieldBuilder = schemaBuilder.AddSimpleField("m_RotationRandomnessZ", typeof(double));
                    fieldBuilder.SetSpec(SpecTypeId.Length);
                    fieldBuilder = schemaBuilder.AddSimpleField("m_ScaleRandomness", typeof(double));
                    fieldBuilder.SetSpec(SpecTypeId.Length);
                    fieldBuilder = schemaBuilder.AddSimpleField("m_ScaleRandomnessX", typeof(double));
                    fieldBuilder.SetSpec(SpecTypeId.Length);
                    fieldBuilder = schemaBuilder.AddSimpleField("m_ScaleRandomnessY", typeof(double));
                    fieldBuilder.SetSpec(SpecTypeId.Length);
                    fieldBuilder = schemaBuilder.AddSimpleField("m_ScaleRandomnessZ", typeof(double));
                    fieldBuilder.SetSpec(SpecTypeId.Length);

                    m_ProxyItemSchema = schemaBuilder.Finish(); // Exception occurs here....
0 Likes
Message 28 of 30

ptranU2KHX
Advocate
Advocate

You can try to use Schema.Lookup and get the schema if it exists before initializing SchemaBuilder

0 Likes
Message 29 of 30

pfk
Enthusiast
Enthusiast

@ptranU2KHX - thank you for this suggestion.  It in fact fixed the problem!  Although I am unsure why, as that schema would not have been loaded previously (ie. Start Revit2024, load Revit2023 scene, exception about duplicate schema occurs).  So there is definitely something odd happening, but I will gratefully accept your suggestion as a solution.

 

Paul

Message 30 of 30

TiagoCostaJorge
Community Visitor
Community Visitor

How do you do your conditional compilation using ">= 2024"? This looks very promising. I can only use a single conditional compilation symbol per revit version.

Thank you!

0 Likes