[BUG] Hiding not working when exporting images
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
When using the OpenDocumentFile() method to open a document in memory, the ExportImage() method ignores hidden elements. Specifically, methods such as HideCategoriesTemporary(), HideElements(), and HideElementsTemporary() do not have any effect on the visibility of elements during the image export process
Steps to Reproduce:
Open a document in memory using the OpenDocumentFile() method.
Use any of the hiding methods (HideCategoriesTemporary(), HideElements(), HideElementsTemporary()) to hide specific elements or categories.
Call the ExportImage() method to export an image of a view.
Workaround:
Interestingly, if the view.Outline property is accessed before calling ExportImage(), the hidden elements are correctly excluded from the exported image. The fact that accessing view.Outline resolves the issue suggests that there may be an internal state or initialization step that is not being triggered correctly when ExportImage() is called directly. view.get_BoundingBox(null); also works in the same way
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