gcasnapshot

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Visualization
Introduced first in SolidGeometry 5.0, Creation date: 2020-09-28, Last change: 2025-09-14

saves the current figure as JPG-File on the user desktop



See Also: gcasnapshot , copyplot , copyfig , snapplot , smbdrawnow

Example Illustration

 missing image of gcasnapshot(cax,fname)

Syntax

fname=gcasnapshot([cax,fname])

Input Parameter

cax: axis to snap, default is gca
fname: optional file name; default is desktopdir(expname) .png

Output Parameter

fname: file name

Examples


SGliblogo(5)
gcasnapshot(gca)




Copyright 2020-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth

Algorithm (Workflow)

This function, gcasnapshot, is designed to capture a snapshot of a graphical axis in MATLAB and save it as a PNG file. It is part of the Solid Geometry library and is used to document the correct assembly of mechanisms.

Input Parameters

Output

Algorithm Steps

  1. Retrieve the graphical axis (cax) from the input parameters using getfuncparams. If not provided, use the current axis (gca).
  2. Retrieve the filename (fname) from the input parameters using getfuncparams. If not provided, use a default directory and experiment name.
  3. Append the .png extension to the filename.
  4. Capture the current frame of the specified axis using getframe and extract the image data (cdata).
  5. Write the captured image data to a PNG file using imwrite.
  6. If no output is requested (nargout==0), read the image back using imread and display it in a new figure window with imshow.
  7. Set the name of the figure window to the filename.
  8. Return to the original figure window.

Example Usage

To use this function, call it with a Solid Geometry object and a desired filename:

SGwriteSTLplot(SGbox, 'test')
Algorithm explaination created using ChatGPT on 2025-08-19 00:58. (Please note: No guarantee for the correctness of this explanation)

Last html export of this page out of FM database by TL: 2025-09-21