Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Bug: Unable to open Revit 2019 model after saving custom schema in Project Info

16 REPLIES 16
Reply
Message 1 of 17
Innobrix_net
965 Views, 16 Replies

Bug: Unable to open Revit 2019 model after saving custom schema in Project Info

Hello, I seem to running into an issue that is specific to Revit 2019, as it does not happen in 2017, 2018 and 2020 (using the exact same code).

 

For my addin I want to save data into the project information of the document using a custom schema. This is generated using the SchemaBuilder class, where I set the schema properties using the example as shown in the API documation.

 

Adding the schema as a new entity to the document in a transaction succeeds.

And I can use Revit Lookup to inspect the saved data in the document.

 

Now here's the problem that occurs:

I save the document, with the custom schema added, as a new file.

I close the document.

I re-open the newly saved document, and I get the following errors:

First error on open:

First error on openFirst error on open

Second error on open:

Second error on openSecond error on open

 

Now I'm unable to open the Revit document.

 

This can be fixed by opening the document with the Audit checkbox enabled.

Where it prompts the following popup:

screenshot_2019-11-06_10-38-25.png

Where pressing Repair and open will clear any existing Project Information that was stored, and regenerate the default Project Information fields with empty values.

 

Could anybody help me with this?

16 REPLIES 16
Message 2 of 17
jeremytammik
in reply to: Innobrix_net

Sorry to hear that you are running into such an issue.

 

Please note that it is not recommended to store extensible storage data on the project info object:

 

 

For the entire list of extensible storage related discussions, please refer to the corresponding topic group:

 

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 17
Innobrix_net
in reply to: jeremytammik

Thanks for the advice, but apparently the issue lies somewhere else.

I have now revised the storage of data using the DataStorage example from your own blog, and made some elementary data to store. It changes the symptoms, but results in a similar outcome:

  • The document is saved, the schema is added to a DataStorage element
  • The document is closed
  • The document is re-opened (either same run, or a cold start).

Revit then produces an error regarding the unrecoverable state of the application:

The unrecoverable error windowThe unrecoverable error window

And follows up with the generic error report window:

The error report windowThe error report window

 

When audited, Revit removes the DataStorage element without prompting, and the bare document is opened as normal. (The given report was also sent with reference to this forum topic.)

 

I've provided the structure used to create a schema:

public static void CreateExportSchema(Guid applicationGuid)
{
// Create SchemaBuilder to store export window settings
SchemaBuilder schemaBuilder = new SchemaBuilder(ExportSchemaGuid_v1);
schemaBuilder.SetSchemaName("MyExportSettings");

// Allow anyone to read the object but restrict writing this addin only
schemaBuilder.SetReadAccessLevel(AccessLevel.Public);
schemaBuilder.SetWriteAccessLevel(AccessLevel.Application);
schemaBuilder.SetVendorId([REDACTED]); // Is the same as the *.addin file
schemaBuilder.SetApplicationGUID(applicationGuid);

// Create a field to store a export date
FieldBuilder exportDateField = schemaBuilder.AddSimpleField("ExportDate", typeof(string));
exportDateField.SetDocumentation("The last exported date of this project.");

// Create a field to store the export path value
FieldBuilder exportPathField = schemaBuilder.AddSimpleField("ExportPath", typeof(string));
exportPathField.SetDocumentation(
"Destination path where all files will be placed during the export process.");

// Create a field to store the grid cell size XYZ value
FieldBuilder gridCellSizeField = schemaBuilder.AddSimpleField("Size", typeof(XYZ));
gridCellSizeField.SetDocumentation("The size of the elements (in meters).");
gridCellSizeField.SetUnitType(UnitType.UT_Length);

// Create a field to store a grid cell offset XYZ value
FieldBuilder gridOffsetField = schemaBuilder.AddSimpleField("Scale", typeof(XYZ));
gridOffsetField.SetDocumentation("The scale of the elements (in meters).");
gridOffsetField.SetUnitType(UnitType.UT_Length);

// Finish and return the Schema object
ExportSchema = schemaBuilder.Finish();
}

The input application GUID parameter is application.ActiveAddInId.GetGUID(), whereas the schema GUID is a unique value, different from the previous GUID.

 

What could be the reason this fails? Again, it works in 2018, breaks in 2019, and oddly enough works again in 2020.

Message 4 of 17
Innobrix_net
in reply to: Innobrix_net

@jeremytammik Would you be so kind to look at this issue again?

Message 5 of 17
jeremytammik
in reply to: Innobrix_net

Hmmm... Well, I could raise a development issue for the team to research this.

 

However, remember that they are currently focussed on the one or two versions following after Revit 2020.

 

Revit 2019 is pretty antique, in their eyes.

 

You would have to bring an extremely convincing business case to motivate them to do anything to fix a problem in Revit 2019.

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 6 of 17
jeremytammik
in reply to: Innobrix_net

I asked the development team what to do for you. One thing they will definitely request is a minimal reproducible case, so I guess you can go ahead and prepare that:

  

https://thebuildingcoder.typepad.com/blog/about-the-author.html#1b

  

Basically, they need a fool-proof single-click solution to reproduce the problem locally for analysis, debugging, and verifying the fix.

  

Thank you!

  



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 7 of 17
jeremytammik
in reply to: Innobrix_net

I discussed this with the development team, and they are asking me to file a development issue for this.

 

That requires a minimal reproducible case, including a minimal sample model, minimal sample code, and exact steps for reproducing the issue:

 

https://thebuildingcoder.typepad.com/blog/about-the-author.html#1b

 

Can you please provide that so I can share it with them for analysis, fix and verification?

 

Thank you!

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 8 of 17
Innobrix_net
in reply to: jeremytammik

My apologies for the late response, replies didn't seem to come through at all.

I will be preparing a sample today.

Message 9 of 17
Innobrix_net
in reply to: jeremytammik

Here is an archive with a project to run in Revit 2019. Please, refer to the README.md within this attached archive for reproduction steps.

 

The reason we're currently limited to Revit 2019 is because the majority of our clients don't jump the gun on transitioning to newer Revit versions, and most are currently working with 2019.

Message 10 of 17
aalondoqor
in reply to: Innobrix_net

Hi, can you solve this bug?

Message 11 of 17
jeremy_tammik
in reply to: aalondoqor

Dear Adrian,

 

Thank you for bringing up this issue again, and my apologies to @Anonymous for not following up on hs issue two years ago.

 

In the Forge help channel, you say:

 

> I have the same problem in the 2019 and 2022 version; in versions 2014 to 2018, 2020, and 2021 my plugin works fine.

 

Basically, the same applies as above: can you share a minimal reproducible case for me to pass on to the development team for analysis?

 

https://thebuildingcoder.typepad.com/blog/about-the-author.html#1b

 

Alternatively, can you verify that the sample material provided above by @Anonymous exactly covers your problem as well?

 

In that case, I can use that instead.

 

Thank you!

 

Best regards,

 

Jeremy

 

Jeremy Tammik, Developer Advocacy and Support, The Building Coder, Autodesk Developer Network, ADN Open
Message 12 of 17
aalondoqor
in reply to: jeremy_tammik

yes, is the same case exactly

Message 13 of 17
RPTHOMAS108
in reply to: aalondoqor

Have to be careful with Extensible Storage it can cause these issues.

I experienced the same with that sample in Revit 2022 when upgraded, I made the changes to Application.cs enclosed and no longer experienced the same issue.

 

Essentially the changes consisted of constructing the schema when it is needed not at start-up, not passing entities ByRef, looking for an existing schema and creating it if not found (via Schema.Lookup(SchemaGuid)) rather than just supplying GUID:

new Entity(Schema)
instead of
new Entity(GUID)

 

Making use of ExtensibleStorageFilter

 

I guess the failure to open should be investigated 'archive error' regardless but comparison between enclosed and original may indicate the cause.

 

The sample includes producing a library in netcore3.0 and dotnet47. I upgraded to dotnet48 and dropped the netcore3.0 version. Due to referencing 2022 API had to change aspects related to DisplayUnitType. Updated solution enclosed not original.

 

 

Message 14 of 17
jeremy_tammik
in reply to: RPTHOMAS108

Dear Richard, 

 

I am flabbergasted. I never cease to be impressed by your experience and helpfulness. I'll compare the differences. This looks like a very worthwhile blog post topic, don't you think?

 

Cheers,

 

Jeremy

  

Jeremy Tammik, Developer Advocacy and Support, The Building Coder, Autodesk Developer Network, ADN Open
Message 15 of 17
RPTHOMAS108
in reply to: jeremy_tammik

Thanks Jeremy

 

When Extensible storage was introduced we all went through a small period of time when we were using it wrong and we didn't see the implications until later (often the next year when we updated the add-ins but had the old schemas). So will always be an important subject to developers with limited experience of it.

 

I have to thank you really because the majority of my knowledge of this subject is due to the AU handouts you authored that are about on the web.  They may not incorporate the latest ways of obtaining Schema's etc. but the process is still outlined correctly. From what I've seen people often get into difficulties when they go too far away from these ways of doing it. I think the general rule is don't hold onto objects and keep interactions as finite as possible. There is also a good basic example in RevitAPI.chm under SchemaBuilder.

 

If you conclude my fixes solved the issue or even if you demonstrate a better way (I did rewrite in a bit of a hurry) would be happy to read that on the blog.

 

We could ask Autodesk to find a more graceful way for Revit to handle the issue but I think that is perhaps easier said than done (is a memory issue, is not new, we all have our part to play in terms of program stability). Often if you can't open a file it may be possible to open it on a Revit version without the add-ins. The add-in in question was creating the schema OnStartUp so would have already put something in memory before the document with the conflict was opened (could open it without the add-in when I checked later).

Message 16 of 17
aalondoqor
in reply to: RPTHOMAS108

thank you all very much, fix my problem with the example file supplied by RPTHOMAS108, thanks for sharing your knowledge

Message 17 of 17
cfallonPGHQ3
in reply to: aalondoqor

I apologize for reopening this thread. I came across this when encountering similar issues. As described, I was able to fix the problem by taking the Schema registration out of the OnStartup method. I wanted to follow up because, in the testing process, I believe I may have isolated the root cause of the issue. It seems that this bug only occurs when building the Schema in the "OnStartup" method AND when the "SetVendorId" is called. My gut is telling me that there is potentially a race condition between Revit reading the .addin manifest and the Schema registration where the VendorId may not be known at the time the Schema is registered. Hope this helps!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Customer Advisory Groups


Rail Community