When using the embedding instance, the following API will cause the exported result images to have only the Legend without the contour plot.
- Dominant language
- Python
- Stars
- 83
- Forks
- 37
- Avg merge
- 1d 3m
- Merged PRs (30d)
- 26
Description
### 🔍 Before submitting the issue
- [x] I have searched among the existing issues
- [x] I am using a Python virtual environment
### 🐞 Description of the bug
When using the embedding instance, the following API will cause the exported result images to have only the Legend without the contour plot:
Graphics.ViewOptions.ResultPreference.GeometryView = MechanicalEnums.Graphics.GeometryView.CappedIsosurface
Graphics.ViewOptions.ResultPreference.CappingType = MechanicalEnums.Graphics.CappingType.Top
Graphics.ViewOptions.ResultPreference.CappingType = MechanicalEnums.Graphics.CappingType.Bottom
In remote session mode, if batch=True (starting Mechanical in batch processing mode), the contour plot remains invisible after calling the aforementioned API. However, when batch=False (starting Mechanical in interactive graphical user interface (GUI) mode), the contour plot becomes visible. Clearly, this is a BUG.
### 📝 Steps to reproduce
Set camera orientation
graphics = app.Graphics
camera = graphics.Camera
camera.SetSpecificViewOrientation(ViewOrientationType.Front)
# Set camera settings for 720p resolution
image_export_format = GraphicsImageExportFormat.PNG
graphics_image_export_settings = Ansys.Mechanical.Graphics.GraphicsImageExportSettings()
graphics_image_export_settings.Capture=GraphicsCaptureType.ImageAndLegend
graphics_image_export_settings.Resolution = GraphicsResolutionType.EnhancedResolution
graphics_image_export_settings.Background = GraphicsBackgroundType.White
graphics_image_export_settings.CurrentGraphicsDisplay = False
graphics_image_export_settings.Width = 720
graphics_image_export_settings.Height = 720
# Set the path for the output files (images, gifs, mechdat)
output_path = Path.cwd() / "out"
model = app.Model
Tree = app.Tree
analysis = app.DataModel.GetObjectsByName("Static Structural")[0]
directional_deformation = app.DataModel.GetObjectsByName("Total Deformation")[0]
directional_deformation.Activate()
MechanicalEnums= Ansys.Mechanical.DataModel.MechanicalEnums
### **# This step will cause the contour plot to be invisible.
graphics.ViewOptions.ResultPreference.GeometryView = MechanicalEnums.Graphics.GeometryView.CappedIsosurface
graphics.ViewOptions.ResultPreference.CappingType = MechanicalEnums.Graphics.CappingType.Top
graphics.ViewOptions.ResultPreference.IsoSurfaceValue = Quantity('100')**
# Set the camera to fit the model
graphics.Camera.FocalPoint = Point([0.0, 0.0, 0.0], 'm')
camera.SetFit()
# Set the image name and path for the object
image_path = str(output_path / f"contact pressure.png")
# Export the image of the object
app.Graphics.ExportImage(image_path, image_export_format, graphics_image_export_settings)
app.save(str(results_path))
# Close the app
app.close()
### 💻 Which operating system are you using?
Windows
### 📀 Which ANSYS version are you using?
2024R2
### 🐍 Which Python version are you using?
3.12
### 📦 Installed packages
```shell
ansys-dpf-core==0.14.1
ansys-mechanical-core==0.11.34
ansys-tools-visualization-interface==0.12.1
backports.tarfile==1.2.0
ipykernel==7.1.0
jaraco.collections==5.1.0
openpyxl==3.1.5
pandas==2.3.3
pip-chill==1.0.3
scipy==1.16.2
tomli==2.0.1
typing==3.7.4.3
usd-core==25.8
```
Contributor guide
Research direction
Start by reproducing the issue with the embedding instance in remote batch mode, comparing app.Graphics.ExportImage behavior with batch=False. Inspect the graphics.ViewOptions.ResultPreference settings for CappedIsosurface and Top or Bottom capping; done means exported images contain the contour plot as well as the legend in batch mode.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100