SamDiagramDownloader#

class ansys.sam.sysml2.diagrams.tools.sam_diagram_downloader.SamDiagramDownloader(connector: ansys.sam.sysml2.diagrams.api.SamApiConnector, project_id: str)#

Provides for managing and downloading diagrams.

Overview#

download_diagram

Download a single diagram and save it to disk.

download_all_diagrams

Download all diagrams as a ZIP archive.

Import detail#

from ansys.sam.sysml2.diagrams.tools.sam_diagram_downloader import SamDiagramDownloader

Method detail#

SamDiagramDownloader.download_diagram(diagram_id: str, path: str | pathlib.Path, file_format: str = 'svg', filename: str = '') str#

Download a single diagram and save it to disk.

Parameters:
diagram_idstr

ID of the diagram to download.

pathstr or Path

Destination file or directory.

file_formatstr

Format of the diagram ('svg', 'png', or 'jpeg').

filenamestr, optional

Name of the file. The default is the diagram ID.

Returns:
str

Return the path of the file created.

Raises:
DiagramNotAvailableException

If diagram functionality is not available for this project.

DiagramConnectorException

If the download fails or HTTP response is not 200.

SamDiagramDownloader.download_all_diagrams(path: str | pathlib.Path, file_format: str = 'svg', filename: str = '') str#

Download all diagrams as a ZIP archive.

Parameters:
pathstr or Path

Destination directory or file path for the ZIP archive.

file_formatstr, default: ‘svg’

Format of the diagrams ('png', 'jpeg', or 'svg').

filenamestr, optional

Name of the file. The default is '{project_id}_{file_format}_diagrams.zip'.

Returns:
str

Path to the saved ZIP archive.

Raises:
DiagramConnectorException

If the download fails or HTTP response is not 200.