[BUG] ExportImage breaks the in-memory model

[BUG] ExportImage breaks the in-memory model

nice3point
Advocate Advocate
710 Views
13 Replies
Message 1 of 14

[BUG] ExportImage breaks the in-memory model

nice3point
Advocate
Advocate

The OpenDocumentFile() method in the Autodesk.Revit.ApplicationServices.Application class is documented as follows:
"This method opens the document into memory but does not make it visible to the user in any way."

 

However, I've identified a scenario where this behavior is broken, causing the document to become visible to the user, like the behavior of OpenAndActivateDocument().

 

Steps to Reproduce:

  1. Use the OpenDocumentFile() method to open a document in memory.

  2. Call the ExportImage() method to export an image of a view.

  3. Observe the behavior under the following conditions:

    • If the view type being exported matches the currently active view type (e.g., both are 3D views), the document remains invisible to the user.

    • If the view type being exported does not match the currently active view type (e.g., a ViewPlan is active, and a 3D view is being exported), the document becomes visible to the user.

 

 

Sample code reproducing the issue is attached

 

Impact:

 

This behavior disrupts the expected CodeFlow, as the document visibility is changed unintentionally. This issue is particularly critical for one application with over 100,000 users, as it can lead to inconsistent user experiences and potential workflow interruptions.

 

Affected Revit versions:

 

2022-2025, Preview

0 Likes
711 Views
13 Replies
Replies (13)
Message 2 of 14

jeremy_tammik
Alumni
Alumni

Dear Roman,

 

Thank you for your report, clear description and sample material. Sorry to hear about this.

  

I logged the issue REVIT-232473 [ExportImage unintentionally displays BIM to user violating official docs] with our development team for this on your behalf as it requires further exploration and possibly a modification to our software. Please make a note of this number for future reference.

You are welcome to request an update on the status of this issue or to provide additional information on it at any time quoting this change request number.

  

If it is especially important and urgent for you, you might also want to mention this ticket number in the preview discussion forum, where you have access to chat directly with the development team.

 

Best regards,

 

Jeremy

   

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

jeremy_tammik
Alumni
Alumni

Same thing here; the development team requests: Please confirm this works as expected in Revit UI and the problem is API only. Thank you!

   

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

nice3point
Advocate
Advocate

@jeremy_tammikconfirm, the problem is related only to the API method OpenDocumentFile, in the UI version everything works properly

0 Likes
Message 5 of 14

jeremy_tammik
Alumni
Alumni

Thank you for the confirmation. The development team suggests: 

  

I note that the transaction is not committed after the categories are hidden.
I suspect that committing the transaction, and only then exporting the resulting view will fix the problem.

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

nice3point
Advocate
Advocate

No, the transaction has no effect at all. Export inside the transaction, after the commit, the result is the same I've attached the code to the ticket, it contains a fully automated script, with an built in family export.

 

"I suspect" - don't suspect, let the developers run it. Isn't that a commit?)

nice3point_0-1738609154493.png

 

0 Likes
Message 7 of 14

jeremy_tammik
Alumni
Alumni

Sorry, my mistake. I think the development team comment on commit was referring to your other issue. Could you check there as well, please? Thank you!

  

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

nice3point
Advocate
Advocate

I checked this before posting on the forum, the answer is the same, Commit before or after export has no effect on the 2 problems described

0 Likes
Message 9 of 14

jeremy_tammik
Alumni
Alumni

Thank you for your thorough checking.

   

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 10 of 14

jeremy_tammik
Alumni
Alumni

Dear Roman,

 

Thank you for reporting this and your patience.

 

The development team closed the issue REVIT-232473 [ExportImage unintentionally displays BIM to user violating official docs] as 'Code Fix Needed' and submitted a new ticket to perform the necessary work, REVIT-233525 [ExportImage unintentionally displays BIM to user violating official docs]. Please make a note of this number for future reference.

 

One comment that they added says, 'The STR are correct. The provided code is misleading.'

 

Maybe this correlates with the comments and suggestions above by your peers 🙂

 

Best regards,

 

Jeremy

   

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 11 of 14

nice3point
Advocate
Advocate

Many thanks Jeremy, honestly don't know what misled them but it's good that Revit team figured it out 😉😂

0 Likes
Message 12 of 14

jeremy_tammik
Alumni
Alumni

🙂  I don't know what they mean either. 

   

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

jeremy_tammik
Alumni
Alumni

REVIT-233525 [ExportImage unintentionally displays BIM to user violating official docs] is now fixed, closed and submitted for a future release. Not the current preview release, though. Future future. 

   

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 14 of 14

nice3point
Advocate
Advocate

Thanks 🙂

0 Likes