Viewer#
- Usage:
Viewer Class API Wrapper
- class Viewer[source]#
Bases:
object
Wrapper for Viewer class of Moldflow Synergy.
- property active_clipping_plane: EntList#
Gets the active clipping plane.
- Returns:
The active clipping plane.
- Return type:
- add_bookmark(name, normal_view, up_view, focal_point, eye_position, clipping_range_min, clipping_range_max, view_angle, parallel_scale)[source]#
Adds a bookmark with the given parameters.
- Parameters:
name (str) – The name of the bookmark.
normal_view (Vector | None) – The normal view vector.
up_view (Vector | None) – The up view vector.
focal_point (Vector | None) – The focal point vector.
eye_position (Vector | None) – The eye position vector.
clipping_range_min (float) – The minimum clipping range.
clipping_range_max (float) – The maximum clipping range.
view_angle (float) – The view angle.
parallel_scale (float) – The parallel scale.
- Return type:
None
- center(center_x, center_y)[source]#
Centers the view at the given coordinates.
- Parameters:
center_x (float) – The x-coordinate to center on.
center_y (float) – The y-coordinate to center on.
- Return type:
None
- create_bookmark(name)[source]#
Creates a bookmark with the given name.
- Parameters:
name (str) – The name of the bookmark.
- Return type:
None
- create_clipping_plane(normal, distance)[source]#
Creates a clipping plane with the given normal and distance.
- create_default_clipping_plane()[source]#
Creates a default clipping plane.
- Returns:
Object containing created clipping plane.
- Return type:
- delete_bookmark(name)[source]#
Deletes a bookmark with the given name.
- Parameters:
name (str) – The name of the bookmark.
- Return type:
None
- delete_clipping_plane(plane)[source]#
Deletes the given clipping plane.
- Parameters:
plane (EntList | None) – The clipping plane to delete.
- Return type:
None
- delete_clipping_plane_by_id(plane_id)[source]#
Deletes clipping by plane ID.
- Parameters:
plane_id (int) – The ID of the plane.
- Return type:
None
- enable_clipping_plane(plane, enable)[source]#
Enables or disables the given clipping plane.
- Parameters:
plane (EntList | None) – The clipping plane to enable or disable.
enable (bool) – Whether to enable or disable the clipping plane.
- Return type:
None
- enable_clipping_plane_by_id(plane_id, enable)[source]#
Enables or disables clipping by plane ID.
- Parameters:
plane_id (int) – The ID of the plane.
enable (bool) – Whether to enable or disable clipping.
- Return type:
None
- get_first_clipping_plane()[source]#
Gets the first clipping plane.
- Returns:
The first clipping plane.
- Return type:
- get_histogram_location()[source]#
Gets the histogram location.
- Returns:
The histogram location.
- Return type:
- get_min_max_maximum_label_location()[source]#
Gets the maximum label location for the min/max plot.
- Returns:
The maximum label location.
- Return type:
- get_min_max_minimum_label_location()[source]#
Gets the minimum label location for the min/max plot.
- Returns:
The minimum label location.
- Return type:
- get_number_frames_by_name(plot_name)[source]#
Gets the number of frames for the given plot. :type plot_name:
str
:param plot_name: The name of the plot. :type plot_name: str- Returns:
The number of frames.
- Return type:
int
- get_plot(plot_id)[source]#
Get a plot by its ID.
- Parameters:
plot_id (int) – The ID of the plot.
- Returns:
The plot with the given ID.
- Return type:
- go_to_bookmark(name)[source]#
Goes to a bookmark with the given name.
- Parameters:
name (str) – The name of the bookmark.
- Return type:
None
- go_to_standard_view(name)[source]#
Go to a standard view
- Parameters:
name (StandardViews | str) – The name of the standard view.
- Return type:
None
- hide_plot(plot)[source]#
Hide the given plot.
- Parameters:
plot (Plot | None) – The plot to hide.
- Return type:
None
- is_play_animation()[source]#
Checks if the animation is currently playing.
- Returns:
True if the animation is playing, False otherwise.
- Return type:
bool
- modify_clipping_plane(plane, normal, distance)[source]#
Modifies the given clipping plane with the new normal and distance.
- modify_clipping_plane_by_id(plane_id, normal, distance)[source]#
Modifies the clipping plane with the given ID with the new normal and distance.
- Parameters:
plane_id (int) – The ID of the clipping plane to modify.
normal (Vector | None) – The new normal vector of the clipping plane.
distance (float) – The new distance from the origin to the clipping plane.
- Return type:
None
- overlay_plot(plot)[source]#
Overlays a plot on another plot in the viewer
- Parameters:
plot (Plot | None) – The plot to overlay.
- Return type:
None
- pan(x, y)[source]#
Pans the view
- Parameters:
x (float) – Pan Factor, < 0 to move to the left > 0 to move to the right
y (float) – Pan Factor, < 0 to move to the bottom > 0 to move to the top
- Return type:
None
Notes
factors are normalized to the screen height, i.e., a factor of 1 moves the model by one screen-height to the top
- rotate(angle_x, angle_y, angle_z)[source]#
Rotates the view to the given set of angles.
- Parameters:
angle_x (float) – The rotation angle around the x-axis.
angle_y (float) – The rotation angle around the y-axis.
angle_z (float) – The rotation angle around the z-axis.
- Return type:
None
- rotate_by(angle_x, angle_y, angle_z)[source]#
Rotates by the given angles.
- Parameters:
angle_x (float) – The rotation angle around the x-axis.
angle_y (float) – The rotation angle around the y-axis.
angle_z (float) – The rotation angle around the z-axis.
- Return type:
None
- rotate_x(angle_x)[source]#
Rotates the view about the X axis to a specified angle
- Parameters:
angle_x (float) – The rotation angle around the x-axis.
- Return type:
None
- rotate_x_by(angle_x)[source]#
Rotates the view about the X axis by a specified angle
- Parameters:
angle_x (float) – The rotation angle around the x-axis.
- Return type:
None
- rotate_y(angle_y)[source]#
Rotates the view about the Y axis to a specified angle
- Parameters:
angle_y (float) – The rotation angle around the y-axis.
- Return type:
None
- rotate_y_by(angle_y)[source]#
Rotates the view about the Y axis by a specified angle
- Parameters:
angle_y (float) – The rotation angle around the y-axis.
- Return type:
None
- rotate_z(angle_z)[source]#
Rotates the view about the Z axis to a specified angle
- Parameters:
angle_z (float) – The rotation angle around the z-axis.
- Return type:
None
- rotate_z_by(angle_z)[source]#
Rotates the view about the Z axis by a specified angle
- Parameters:
angle_z (float) – The rotation angle around the z-axis.
- Return type:
None
- property rotation_x: float#
Get the current rotation around the x-axis in degrees.
- Returns:
The rotation around the x-axis.
- Return type:
float
- property rotation_y: float#
Get the current rotation around the y-axis in degrees.
- Returns:
The rotation around the y-axis.
- Return type:
float
- property rotation_z: float#
Get the current rotation around the z-axis in degrees.
- Returns:
The rotation around the z-axis.
- Return type:
float
- save_animation(filename, speed, prompts=False)[source]#
Saves the current view as an animation.
- Parameters:
filename (str) – The name of the file to save the animation to.
speed (AnimationSpeed | str) – The speed of the animation.
prompts (bool) – Whether to include prompts in the animation.
- Returns:
True if successful, False otherwise.
- Return type:
bool
- save_axis_image(filename)[source]#
Saves the current axis as an image.
- Parameters:
filename (str) – The name of the file to save the image to.
Note:The image scale and size is the same as on the screen @
- Returns:
True if successful, False otherwise.
- Return type:
bool
- save_image(filename, x=0, y=0, result=False, legend=False, axis=False, rotation=False, scale_bar=False, plot_info=False, study_title=False, ruler=False, logo=False, histogram=False, min_max=False)[source]#
Saves the current view as an image.
- Parameters:
filename (str) – The name of the file to save the image to.
x (int) – The width of the image.
y (int) – The height of the image.
result (bool) – Whether to include results in the image.
legend (bool) – Whether to include the legend in the image.
axis (bool) – Whether to include axes in the image.
rotation (bool) – Whether to include rotation in the image.
scale_bar (bool) – Whether to include a scale bar in the image.
plot_info (bool) – Whether to include plot information in the image.
study_title (bool) – Whether to include study title in the image.
ruler (bool) – Whether to include a ruler in the image.
logo (bool) – Whether to include a logo in the image.
histogram (bool) – Whether to include a histogram in the image.
min_max (bool) – Whether to include min/max values in the image.
- Returns:
True if successful, False otherwise.
- Return type:
bool
- save_image_legacy(filename, x=None, y=None)[source]#
Save image using legacy behavior only (V1/V2): - filename only -> SaveImage(filename) - filename and positive x,y -> SaveImage2(filename, x, y) :type filename:
str
:param filename: Output image path. :type x:int
|None
:param x: Width in pixels (must be > 0 when provided). :type y:int
|None
:param y: Height in pixels (must be > 0 when provided).- Returns:
True if successful (V2 returns its bool; V1 coerced to True).
- Return type:
bool
- Raises:
TypeError – If types are invalid.
ValueError – If only one of x/y provided or sizes are not positive.
- save_plot_scale_image(filename)[source]#
Saves the current plot scale as an image.
- Parameters:
filename (str) – The name of the file to save the image to.
Note:The image scale and size is the same as on the screen @
- Returns:
True if successful, False otherwise.
- Return type:
bool
- set_banded_contours(plot_name, banding, num_colours)[source]#
Sets banded contours for the given plot.
- Parameters:
plot_name (str) – The name of the plot.
banding (bool) – Whether to enable or disable banding.
num_colours (int) – The number of colours to use for banding.
- Return type:
None
- set_histogram_location(x, y, x_size, y_size)[source]#
Sets the histogram location.
- Parameters:
x (float) – The x-coordinate of the bottom left corner of the histogram location.
y (float) – The y-coordinate of the bottom left corner of the histogram location.
x_size (float) – The width of the histogram.
y_size (float) – The height of the histogram.
- Return type:
None
- set_min_max_maximum_label_location(x, y, x_size, y_size)[source]#
Sets the maximum label location for the min/max plot.
- Parameters:
x (float) – The x-coordinate of the bottom left corner of the maximum label location.
y (float) – The y-coordinate of the bottom left corner of the maximum label location.
x_size (float) – The width of the maximum label.
y_size (float) – The height of the maximum label.
- Return type:
None
- set_min_max_minimum_label_location(x, y, x_size, y_size)[source]#
Sets the minimum label location for the min/max plot.
- Parameters:
x (float) – The x-coordinate of the bottom left corner of the minimum label location.
y (float) – The y-coordinate of the bottom left corner of the minimum label location.
x_size (float) – The width of the minimum label.
y_size (float) – The height of the minimum label.
- Return type:
None
- set_view_mode(perspective)[source]#
Enables parallel or perspective projection.
- Parameters:
perspective (ViewModes | int) – The perspective mode.
- Return type:
None
- set_view_size(size_x, size_y)[source]#
Sets the view size.
- Parameters:
size_x (int) – The width of the view.
size_y (int) – The height of the view.
- Returns:
True if successful, False otherwise.
- Return type:
bool
- show_plot(plot)[source]#
Show the given plot.
- Parameters:
plot (Plot | None) – The plot to show.
- Return type:
None
- show_plot_by_name(plot_name)[source]#
Shows the plot with the given name.
- Parameters:
plot_name (str) – The name of the plot to show.
- Return type:
None
- show_plot_frame(plot, frame)[source]#
Shows the given plot frame.
- Parameters:
plot (Plot | None) – The plot to show.
frame (int) – The frame number to show.
- Return type:
None
- show_plot_frame_by_name(plot_name, frame)[source]#
Shows the plot frame with the given name and frame number.
- Parameters:
plot_name (str) – The name of the plot.
frame (int) – The frame number to show.
- Return type:
None
- property view_size_x: int#
Get the current view size width in pixels on the window restored size and position
- Returns:
The width of the view.
- Return type:
int
- property view_size_y: int#
Get the current view size height in pixels on the window restored size and position
- Returns:
The height of the view.
- Return type:
int