graphics.py — Graphics Module

Wraps SpinFire.Scripting.API.Utilities.GraphicsUtilities. Covers screenshots/image export, file import/save, coordinate systems, item visibility and standard views.

Screenshots, Import & Save

Function

Parameters

Returns

Description

CopyScreenshotToClipboard(width=None, height=None)

width/height (int, optional; 300–16384 / 300–8640)

Result message

Copies a screenshot of the view to the clipboard.

ExportImage(path=None, width=None, height=None)

path (str, optional; else a save dialog is shown); width/height as above

Result message

Exports the view as an image (.bmp, .emf, .exif, .gif, .jpg, .jpeg, .png, .tiff, .wmf).

ImportFile(path=None)

path (str)

Result message

Imports a file.

SaveCurrentFile()

none

Result message

Saves to the current file path.

SaveFile(path, replaceExistingFile=False)

path (str); replaceExistingFile (bool)

Result message

Saves to the given file path.

Coordinate Systems

Function

Parameters

Returns

Description

GetCoordinateSystems()

none

CoordinateSystemsData

Gets all coordinate systems.

GetCoordinateSystem(coordinateSystem, baseCoordinateSystem=None)

coordinateSystem (str/int); baseCoordinateSystem (str/int, optional — defaults to the active one)

CoordinateSystemData

Gets a coordinate system, optionally relative to a base.

CreateCoordinateSystem(coordinateSystem, name, position, orientation, rotation)

coordinateSystem (str/int, 0 = global); name (str); position (CSPositionParams); orientation (CSOrientationParams); rotation (CSRotationParams)

CoordinateSystemData

Creates a new coordinate system, optionally with interactive picking.

UpdateCoordinateSystem(coordinateSystem, name, position, orientation, rotation)

Same as above; any argument may be None to keep its current value

CoordinateSystemData

Updates an existing coordinate system.

UpdateCoordinateSystemName(coordinateSystem, name)

coordinateSystem (str/int); name (str)

CoordinateSystemData

Convenience wrapper — updates only the name.

UpdateCoordinateSystemPosition(coordinateSystem, position)

coordinateSystem; position

CoordinateSystemData

Convenience wrapper — updates only the position.

UpdateCoordinateSystemOrientation(coordinateSystem, orientation)

coordinateSystem; orientation

CoordinateSystemData

Convenience wrapper — updates only the orientation.

UpdateCoordinateSystemRotation(coordinateSystem, rotation)

coordinateSystem; rotation

CoordinateSystemData

Convenience wrapper — updates only the rotation.

ShowCoordinateSystem(coordinateSystem) / HideCoordinateSystem(coordinateSystem)

coordinateSystem (str/int)

Result message

Shows/hides a coordinate system.

SetCoordinateSystemActive(coordinateSystem)

coordinateSystem (str/int)

Result message

Makes a coordinate system the active one.

Visibility & Views

Function

Parameters

Returns

Description

ZoomFit()

none

Result message

Zooms to fit all visible items.

ShowItem() / HideItem() / ToggleVisibilityItem()

none

Result message

Shows, hides, or toggles visibility of all selected items.

ApplyStandardView(standardView)

standardView (StandardView enum — Default, Front, Back, Top, Bottom, Right, Left, TopRight, BottomRight, BottomLeft, TopLeft, Standard2D, CrossSection)

Result message

Applies a standard camera view to the active 3D view.

Usage

 1import spinfirescript as sfs
 2from SpinFire.Scripting.API.Geometry import StandardView
 3import SpinFire.Scripting.API.Geometry as sfgeom
 4
 5sfs.ExportImage("screenshot.png")
 6sfs.ApplyStandardView(StandardView.TopRight)
 7
 8# Pick a coordinate system origin/axis interactively, then rotate 150 degrees about X.
 9systemData = sfs.CreateCoordinateSystem(
10    0, "New coordinate system",
11    sfgeom.CSPositionParams(pickType=sfgeom.CSPositionParams.PositionPickType.Point),
12    sfgeom.CSOrientationParams(sfgeom.AxisType.Z, pickType=sfgeom.CSOrientationParams.OrientationPickType.Axis),
13    sfgeom.CSRotationParams(sfgeom.AxisType.X, 150))
14print(systemData.CoordinateSystem.MatrixArray)