gcode_reader.visualize¶
Functions¶
|
Generates and displays a 3D plot from a AdditivePart object. |
|
Creates a 3D plot of an Event Series colored by a continuous scalar value. |
|
Generates and displays a 3D plot of a G-code toolpath from a DataFrame. |
|
"Generates and displays a 3D plot from a processed Operation object. |
Module Contents¶
- gcode_reader.visualize.plot_additive_part(part: gcode_reader.emulate.additive_part.AdditivePart, layer_range=None, layer_index=None, **kwargs)[source]¶
Generates and displays a 3D plot from a AdditivePart object.
This function visualizes the depoisition toolpath defined in an AdditivePart for a provided range of layers, or a specified layer index.
- Parameters:
part (AdditivePart) – The AdditivePart object to be plotted.
layer_range (tuple, optional) – A range of layer indices to plot.
layer_index (int, optional) – A specified layer index to plot. Takes precidence over layer_range.
**kwargs – Additional keyword arguments to pass to plotly.express.line_3d.
- Returns:
The Plotly Figure object.
- Return type:
plotly.graph_objects.Figure
- gcode_reader.visualize.plot_event_series(event_series: pandas.DataFrame, color_by='e', colorscale='Viridis', **kwargs)[source]¶
Creates a 3D plot of an Event Series colored by a continuous scalar value.
- Parameters:
event_series (pd.DataFrame) – DataFrame containing the event series data. Must include columns for ‘x’, ‘y’, ‘z’, ‘e’, ‘time’.
color_by (str, optional) – The name of the column used to color the line. Defaults to “e”.
colorscale (str, optional) – The name of the Plotly colorscale to use for the gradient. Defaults to “Viridis”.
show (bool, optional) – If True, the plot is displayed immediately. Else return the figure. Defaults to True.
**kwargs – Additional keyword arguments to pass to fig.update_layout.
- Returns:
The Plotly Figure object.
- Return type:
plotly.graph_objects.Figure
- gcode_reader.visualize.plot_gcode_dataframe(df, x='x', y='y', z='z', tag=None, **kwargs)[source]¶
Generates and displays a 3D plot of a G-code toolpath from a DataFrame.
- Parameters:
df (pd.DataFrame) – DataFrame containing processed G-code. It is expected to have columns for coordinates and an optional ‘tags’ column.
x (str, optional) – The name of the column containing the X-axis data. Defaults to “x”.
y (str, optional) – The name of the column containing the Y-axis data. Defaults to “y”.
z (str, optional) – The name of the column containing the Z-axis data. Defaults to “z”.
tag (str, optional) – A tag to filter the DataFrame. If provided, only rows where this tag is present in the ‘tags’ column will be plotted. Defaults to None.
**kwargs – Additional keyword arguments to pass to plotly.express.line_3d.
- Returns:
The Plotly Figure object.
- Return type:
plotly.graph_objects.Figure
- gcode_reader.visualize.plot_operation(operation: gcode_reader.emulate.operations.Operation, command_type: type = None, **kwargs)[source]¶
“Generates and displays a 3D plot from a processed Operation object.
This function visualizes the toolpath defined by an Operation. It can either plot the entire path as a single continuous line or plot only the segments that correspond to a specific command type (e.g., Move) as separate polylines.
- Parameters:
operation (Operation) – The processed Operation object to be plotted.
command_type (type, optional) – A command class used to filter the plot. If provided, only toolpath segments generated by this command type (or its subclasses) will be shown. Defaults to None.
**kwargs – Additional keyword arguments to pass to plotly.express.line_3d.
- Returns:
The Plotly Figure object.
- Return type:
plotly.graph_objects.Figure
- Raises:
ValueError – If the operation has not been processed or if the number of commands does not match the number of process data points.