This commit is contained in:
Nicolas Predella 2026-05-14 21:28:17 +03:00
parent 57a5570e14
commit 76ad7c2018
4 changed files with 31 additions and 0 deletions

View file

@ -832,6 +832,34 @@ class SLICENODE_GcodeToFile(ExecSliceNode):
return 'ok'
@register_class
class SLICENODE_GcodeToTextBlock(ExecSliceNode):
bl_label = "Gcode to Text Block"
button_label = "Create Text Block"
def init(self, context):
self._init_exec()
self.add_input("SLICESOCK_Gcode")
def evaluate(self, operator=None):
gcode: str = resolve_input(self.inputs.get("Gcode"))
if not gcode:
return 'ok'
text_block = bpy.data.texts.new(name="NodeSlicer_Gcode.gcode")
text_block.from_string(gcode)
# Attempt to show in an open text editor
assert bpy.context.window_manager
for window in bpy.context.window_manager.windows:
for area in window.screen.areas:
if area.type == 'TEXT_EDITOR':
for space in area.spaces:
if space.type == 'TEXT_EDITOR':
space.text = text_block
return 'ok'
@register_class
class SLICENODE_StartPrint(ExecSliceNode):
bl_label = "Start Print"

View file

@ -76,6 +76,7 @@ class SLICENODE_MT_Menu(Menu):
layout.operator("node.add_node", text="Boolean Paths").type = "SLICENODE_JoinSlices"
layout.separator()
layout.operator("node.add_node", text="Gcode to File").type = "SLICENODE_GcodeToFile"
layout.operator("node.add_node", text="Gcode to Text Block").type = "SLICENODE_GcodeToTextBlock"
layout.operator("node.add_node", text="Start Print").type = "SLICENODE_StartPrint"
layout.operator("node.add_node", text="Gcode to Mesh").type = "SLICENODE_GcodeToMesh"
layout.operator("node.add_node", text="Executor").type = "SLICENODE_Executor"

View file

@ -515,6 +515,7 @@ class Pather(object):
last_z = z0
gcode.append(f"G0 X{x0:.3f} Y{y0:.3f} Z{z0:.3f}")
old_x, old_y, old_z = x0, y0, z0
fr = self.feedrate
old_fr = 0

View file

@ -71,5 +71,6 @@ All nodes are found in the **Add (Shift+A)** menu under the **SliceNodes** categ
- **Header**: Toggles the generation of standard NodeSlicer G-code headers and units setup.
- **Load Gcode**: Reads a G-code file from disk.
- **Gcode to File**: Writes G-code string to a file on disk.
- **Gcode to Text Block**: Creates a new Blender text block containing the G-code and opens it in any active text editors.
- **Gcode to Mesh**: Decodes G-code and creates a Blender mesh ("Debug" object) for visualization.
- **Test**: Triggers evaluation for debugging purposes.