Revit 2024 changed to ElementId from int to long

Revit 2024 changed to ElementId from int to long

pfk
Enthusiast Enthusiast
743 Views
6 Replies
Message 1 of 7

Revit 2024 changed to ElementId from int to long

pfk
Enthusiast
Enthusiast

My plugin saves information (including ElementId) to the Revit 2023 (and previous versions) scene using Entity.Set<int>. Now ElementId is a long, how do I handle this please? Do I load using Entity.Get<int> or <long>? If I use Get<long>, will older scene load correctly that were saved with Set<int>?

 

Thanks

 

Paul

0 Likes
744 Views
6 Replies
Replies (6)
Message 2 of 7

jeremy_tammik
Alumni
Alumni

Well. The easy, official and standard way would have been to save ElementId in an extensible storage entity using the built-in ElementId support directly.

  

As you (hopefully) know, you cannot modify an existing extensible storage schema.

  

So, my recommendation would be:

  

  • Implement a new extensible storage schema storing ElementId data in either ElementId or 64-bit integers
  • Implement automatic upgrading functionality to automatically upgrade you old schema to the new one whenever old data is encountered
  • Use the new schema henceforth

  

This recommendation is untested and comes with no warranty, so please test it very carefully before you start corrupting your working projects. I am looking forward to hearing how it works for you and whether you can suggest any improvements. Thank you!

 

By the way, here are some other observations on this topic so far:

 

  

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

pfk
Enthusiast
Enthusiast

Thanks Jeremy for your reply.  I was hoping you were not going to suggest that particular recommendation, however I see there is no other way around the problem, so I have implemented it, and it works.

 

However....there is another schema where the ElementId /was/ saved as an ElementId (ie. it contains the following code)

fieldBuilder = schemaBuilder.AddSimpleField("m_MeshElementId", typeof(ElementId));
m_ProxyItemSchema = schemaBuilder.Finish(); // Throws an exception "A different Schema with the same identity already exists."

 

It throws an exception on schemaBuilder.Finish().  So it appears saving of type ElementId is broken in Revit 2024.  Is there a workaround please?

 

Thanks

 

Paul

0 Likes
Message 4 of 7

pfk
Enthusiast
Enthusiast

I am now a little lost on this issue.

 

I am creating the schema with:

 

fieldBuilder = schemaBuilder.AddSimpleField("m_ElementId", typeof(ElementId));

 

 

Then to read/write to that field, I use

 

entity.Set<ElementId>("m_ElementId", this.m_ElementIndex.m_ProxyIndex);
this.m_ElementIndex = new ElementIndex(proxyEntity.Get<ElementId>("m_ElementId"));

 

How can I get the AddSimpleField code to /not/ throw an exception on Revit 2024 after a scene previously saved with Revit 2023 has been loaded please?

 

Thanks

 

Paul

0 Likes
Message 5 of 7

pfk
Enthusiast
Enthusiast

Would it be possible to get a response on this issue please?

 

Thanks

 

Paul

0 Likes
Message 6 of 7

moturi.magati.george
Autodesk
Autodesk

Hi @pfk,

Is your issue similar to the ones faced below in schema upgrade in Revit 2024. If yes, the development team is already aware of the issue and is finalizing on the fix.

https://forums.autodesk.com/t5/revit-api-forum/upgrade-2024-api-causing-schema-error/m-p/12000843#M7...

 

We hope that they will include it in the next update that is yet to be released.
Also, they are looking at the issue with the schema conflict when opening two projects stored with same schema.


  Moturi George,     Developer Advocacy and Support,  ADN Open
0 Likes
Message 7 of 7

pfk
Enthusiast
Enthusiast

Thank you.  I will await the promised fix!

0 Likes