Skip to main content
Solved

ZOS-API question : Turning off Axis when creating Bitmap


Brian

I’m using the ZOS-API (ver. 2024 R1) with C# and creating an Open3DViewerExport (I3DViewerExport) bitmap of the Ray Trace.

The bitmap gets generated to a file but includes the axis (X,Y,Z) in the lower left corner of the image.


The application allows to turn this access off but I don’t see the option within the API.

 

Is there anyway that the API can turn this off as well?

Thanks.

B.

Best answer by Brian

Hi Michael,
 

I think your right. The API is going to provide minimal “customizations” for something that I want.
 

I’m going to give your suggestion a try.

 

Thanks.

B.

View original
Did this topic help you find an answer to your question?

2 replies

MichaelH
Ansys Staff
Forum|alt.badge.img+2
  • Ansys Staff
  • 365 replies
  • April 23, 2025

Hi Brian,

I don’t believe there is a way to turn this off via the API (most of the API focuses on changing the actual optical system, not on visualization).  Although this might not work in all cases, I would simply copy a rectangle from the bottom right of the saved image and paste it over the bottom left to cover up the orientation indicator.  

static void RemoveOrientationIndicator(string filename, int width = 100, int height = 100, int left = 10, int bottom = 10)
{
    string output = Path.GetFileNameWithoutExtension(filename) + "_cleaned" + Path.GetExtension(filename);
    output = Path.Combine(Path.GetDirectoryName(filename), output);

    using (Bitmap bmp = new Bitmap(filename))
    {
        using (Graphics g = Graphics.FromImage(bmp))
        {
            // get the left and right coordinates for the 2 rectangles
            int rightX = bmp.Width - width - left;
            int rightY = bmp.Height - height - bottom; 
            int leftX = left;
            int leftY = bmp.Height - height - bottom;

            // get the left and right rectangles
            var rightRect = new Rectangle(rightX, rightY, width, height);
            var leftRect = new Rectangle(leftX, leftY, width, height);

            // copy & paste from the right side to the left side to hide the indicator
            g.DrawImage(bmp, leftRect, rightRect, GraphicsUnit.Pixel);
        }

        // Save the modified image
        bmp.Save(output);
    }
}

Simply call this function after you have saved the layout via the RunAndWaitForCompletion:

var tool = TheSystem.Tools.Layouts;
var layout = tool.OpenShadedModelExport();
layout.SaveImageAsFile = true;
layout.OutputFileName = bmpOutputName;
layout.RunAndWaitForCompletion();
layout.Close();

RemoveOrientationIndicator(layout.OutputFileName);

I get the following for a before and after (this work for both the white background of Open3DViewerExport and the gradient background of OpenShadedModelExport):

 


Brian
  • Author
  • Infrared
  • 6 replies
  • Answer
  • April 24, 2025

Hi Michael,
 

I think your right. The API is going to provide minimal “customizations” for something that I want.
 

I’m going to give your suggestion a try.

 

Thanks.

B.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings