NOTICE: All information contained herein is, and remains
the property of TechnoCore Automate.
The intellectual and technical concepts contained
herein are proprietary to TechnoCore and dissemination of this information or reproduction of this material
is strictly forbidden unless prior written permission is obtained
from TechnoCore Automate.
ObjServiceStlObjServiceStl is a service for slicing 3D STL models into 2D SVG cross-sections suitable for laser cutting, along with generating a 3D preview image of the model. It inherits from ObjApi.ObjApi.
The service loads an STL file using trimesh, slices the mesh at regular intervals along the Z-axis based on a configurable material thickness, and exports each slice as an SVG file. A 3D preview PNG is also generated using matplotlib.
Service Code: STL
generate_3d_preview(mesh, output_path: str) -> NoneRenders a 3D matplotlib plot of a loaded trimesh mesh and saves it as a PNG image. Configurable via YAML preview settings (face color, alpha, edge color, figure size).
process_stl(mesh, material_thickness: float) -> list | NoneSlices a loaded mesh horizontally at intervals of material_thickness from z_min + material_thickness to z_max. Each slice is converted from Path3D to Path2D and exported as SVG data. Returns a list of (height, svg_data) tuples, or None on error.
Compute(Param1, Param2, Param3)Standard service entry point.
| Parameter | Description |
|---|---|
Param1 |
Path to the STL file |
Param2 |
Material thickness (float, in model units) |
Param3 |
Output directory for SVG slices and preview (defaults to STL file directory) |
Returns "SUCCESS" or "FAIL" and records the model and its slices in the database.
python factory.service/ObjServiceStl.py <stl_path> [OPTIONS]
| Option | Default | Description |
|---|---|---|
--thickness, -t |
1.0 |
Material thickness for slicing |
--output, -o |
local.documents/stl |
Output directory for SVG slices and preview |
python factory.service/ObjServiceStl.py model.stl -t 0.5 -o output/
<model_name>_preview.png — 3D rendered preview of the STL modelslice_0.svg, slice_1.svg, ... — 2D SVG cross-sections at each Z-layerTables are created automatically via create_tables_from_yaml() on init.
def_model_stlTracks each processed STL model. Primary key: (StlCode, Package).
| Column | Type | Description |
|---|---|---|
StlCode |
varchar(255) | Model identifier (<name>_<path_hash>) |
Package |
varchar(100) | Package scope |
Description |
varchar(255) | Auto-generated description |
FilePath |
varchar(255) | Source STL file path |
MaterialThickness |
double | Slicing thickness used |
OutputDirectory |
varchar(255) | Directory where outputs are saved |
Active |
char(1) | Active flag (Y/N) |
Status |
varchar(50) | PENDING, PROCESSING, SUCCESS, or FAIL |
PreviewPath |
varchar(255) | Path to the 3D preview PNG |
SliceCount |
int | Number of slices generated |
CreatedAt |
timestamp | Record creation time |
UpdatedAt |
timestamp | Last update time |
def_model_stl_slicesTracks individual slices per model. Primary key: (StlCode, Package, SliceNumber).
| Column | Type | Description |
|---|---|---|
StlCode |
varchar(255) | Parent model identifier |
Package |
varchar(100) | Package scope |
SliceNumber |
int | Zero-based slice index |
SliceHeight |
double | Z-axis height of the slice |
FilePath |
varchar(255) | Path to the output SVG file |
FileSize |
int | Size of SVG data in bytes |
CreatedAt |
timestamp | Record creation time |
All configurable values are loaded from ObjServiceStl.yaml via get_constants() at init. The YAML file defines:
constants.defaults| Key | Default | Description |
|---|---|---|
material_thickness |
1.0 |
Default slicing thickness |
output_directory |
local.documents/stl |
Default output directory |
constants.preview| Key | Default | Description |
|---|---|---|
figure_size |
10 |
Matplotlib figure width/height |
face_color |
[0.5, 0.5, 1.0] |
RGB face color for 3D preview |
face_alpha |
0.8 |
Face transparency |
edge_color |
k |
Edge color (matplotlib color string) |
constants.slicing| Key | Default | Description |
|---|---|---|
plane_normal |
[0, 0, 1] |
Slicing plane normal vector |
file_prefix |
slice_ |
Output SVG filename prefix |
file_format |
svg |
Output slice file extension |
preview_suffix |
_preview.png |
Preview image filename suffix |
trimesh — STL loading and mesh slicingnumpy — Numeric operations for slice heightsmatplotlib — 3D preview renderingUpdated: 2026-01-28