nodeslicer/doc/NODES.md
2026-05-06 11:12:13 +03:00

68 lines
3.6 KiB
Markdown

# Node & Socket Reference
## Node Sockets
| Socket ID | Type | Underlying Data Structure | Purpose |
|-----------|------|---------------------------|---------|
| `SLICESOCK_Object` | `bpy.types.Object` | Blender RNA Object | Reference to a Blender Object |
| `SLICESOCK_Float` | `float` | Python float | Numeric value |
| `SLICESOCK_Int` | `int` | Python int | Integer value |
| `SLICESOCK_String` | `str` | Python string | Text/Path value |
| `SLICESOCK_Mesh` | `SlicingObject` | NumPy NDArray (Triangles) | Internal mesh data (Transformed/Scaled) |
| `SLICESOCK_Slices` | `list[np.ndarray]` | List of closed paths (N, 3) | Closed manifold contours (Inside/Outside defined) |
| `SLICESOCK_Paths` | `list[np.ndarray]` | List of paths (N, 3) | Generic toolpaths (No defined interior) |
| `SLICESOCK_Gcode` | `str` | Multi-line string | Generated G-code text |
## Detailed Data Types
### SlicingObject (`SLICESOCK_Mesh`)
The `SlicingObject` class wraps a high-performance NumPy representation of a Blender mesh.
- **`.mesh`**: A NumPy `ndarray` of type `float64` with shape `(N, 4, 3)`.
- `N`: Number of triangles.
- `[i, 0:3, :]`: The three vertices of the $i$-th triangle.
- `[i, 3, :]`: The face normal of the $i$-th triangle.
- **Coordinates**: Transformed to world space and scaled by the Blender scene unit scale (multiplied by 1000 for mm-standard G-code).
### Slices (`SLICESOCK_Slices`)
A `list[np.ndarray]` (each `(N, 3)`) containing the results of the slicing operation.
- **Content**: Guaranteed to be closed loops forming a valid manifold boundary.
- **Z-Awareness**: Coordinates are stored as 3D `(X, Y, Z)` to maintain the correct layer height.
- **Topology**: Generated and cleaned using `pyclipper`.
### Paths (`SLICESOCK_Paths`)
A `list[np.ndarray]` (each `(N, 3)`) containing generic toolpaths.
- **Content**: Can be open or closed segments.
- **Z-Awareness**: Coordinates are stored as 3D `(X, Y, Z)`.
- **Source**: Typically generated from `Slices` boundaries via the `Slices to Paths` node.
### Gcode (`SLICESOCK_Gcode`)
A standard Python string containing formatted G-code.
- **Format**: `G0` for travels, `G1` for extrusions.
- **Extrusion**: Calculated as absolute `E` values based on Euclidean distance and a configurable `EXTRUSION_RATE`.
## Nodes
### Input Nodes
- `SLICENODE_InputFloat`: Single float input.
- `SLICENODE_InputInt`: Single integer input.
- `SLICENODE_InputString`: Single string/path input.
- `SLICENODE_InputObject`: Blender object picker.
- `SLICENODE_GcodeBlock`: Manual text area for entering raw G-code.
### Processing Nodes
- `SLICENODE_GetMesh`: Converts a Blender Object into internal `SlicingObject` format.
- `SLICENODE_SliceShells`: Slices a `SlicingObject` into 2D `Slices` at a given layer height.
- `SLICENODE_BufferShells`: Offsets/buffers 2D `Slices` using a "Distance" parameter. Buffers each Z-layer independently to maintain 3D structure and uses winding rules to correctly handle nested holes.
- `SLICENODE_SlicesToPaths`: Extracts the boundaries of `Slices` to create `Paths`.
- `SLICENODE_PathsToGcode`: Converts `Paths` into G-code blocks.
### Joiner Nodes (Variable Inputs)
- `SLICENODE_JoinMesh`: Merges multiple `SlicingObject` instances into one.
- `SLICENODE_JoinPaths`: Merges multiple paths.
- `SLICENODE_JoinGcode`: Concatenates multiple G-code strings with newline separators.
### Action Nodes (Executable)
- `SLICENODE_GcodeToFile`: Writes G-code string to a file on disk.
- `SLICENODE_GcodeToMesh`: Decodes G-code and creates a Blender mesh (Edges) for visualization/debugging.
- `SLICENODE_LoadGcode`: Reads a G-code file from disk into a string.
- `SLICENODE_Test`: Triggers evaluation for debugging purposes.