multiple previews
This commit is contained in:
parent
5aad206c48
commit
efc3c65982
1 changed files with 19 additions and 19 deletions
|
|
@ -1345,7 +1345,7 @@ class SLICENODE_PrusaslicerSlice(SliceNode):
|
|||
def init(self, context):
|
||||
self.add_input("SLICESOCK_PrusaslicerConf", "Config")
|
||||
self.add_input("SLICESOCK_Settings", "Settings")
|
||||
self.add_multi_socket_group("SLICESOCK_Mesh", "SLICESOCK_GcodeRo", name="Slicing Group")
|
||||
self.add_multi_socket_group("SLICESOCK_Mesh", "SLICESOCK_GcodeRo", name="Slicing Group", in_name="Mesh", out_name="Gcode")
|
||||
|
||||
def draw_buttons(self, context, layout):
|
||||
assert layout
|
||||
|
|
@ -1480,15 +1480,15 @@ class SLICENODE_PrusaslicerPreview(ExecSliceNode):
|
|||
|
||||
def init(self, context):
|
||||
self._init_exec()
|
||||
self.add_input("SLICESOCK_Gcode", "Gcode")
|
||||
self.add_multi_socket_group("SLICESOCK_Gcode", name="Gcode")
|
||||
|
||||
def draw_buttons(self, context, layout):
|
||||
super().draw_buttons(context, layout)
|
||||
layout.prop(self, "prusaslicer_executable")
|
||||
|
||||
def evaluate(self, operator=None):
|
||||
gcode: str = self.resolve("Gcode")
|
||||
if not gcode:
|
||||
gcodes: list[str] = [g for g in self.resolve_multi_input("Gcode") if g]
|
||||
if not gcodes:
|
||||
if operator: operator.report({'ERROR'}, "No Gcode to preview")
|
||||
return 'no gcode'
|
||||
|
||||
|
|
@ -1508,33 +1508,33 @@ class SLICENODE_PrusaslicerPreview(ExecSliceNode):
|
|||
abs_path = bpy.path.abspath(cmd_parts[0])
|
||||
if os.path.exists(abs_path):
|
||||
cmd_parts[0] = abs_path
|
||||
|
||||
|
||||
# Final check if command exists
|
||||
if not shutil.which(cmd_parts[0]):
|
||||
if operator: operator.report({'ERROR'}, f"Command or executable not found: {cmd_parts[0]}")
|
||||
return 'error'
|
||||
|
||||
# Write to temp file
|
||||
# We use a named temporary file that stays around for a bit.
|
||||
# PrusaSlicer needs the file to exist when it starts.
|
||||
fd, temp_path = tempfile.mkstemp(suffix='.gcode')
|
||||
# Write to temp files
|
||||
# We use named temporary files that stay around for a bit.
|
||||
# PrusaSlicer needs the files to exist when it starts.
|
||||
try:
|
||||
with os.fdopen(fd, 'w', encoding='utf-8') as f:
|
||||
f.write(gcode)
|
||||
|
||||
cmd = cmd_parts + ["--gcodeviewer", temp_path]
|
||||
|
||||
# Use Popen to not block Blender
|
||||
subprocess.Popen(cmd)
|
||||
|
||||
for gcode in gcodes:
|
||||
fd, temp_path = tempfile.mkstemp(suffix='.gcode')
|
||||
with os.fdopen(fd, 'w', encoding='utf-8') as f:
|
||||
f.write(gcode)
|
||||
|
||||
cmd = cmd_parts + ["--gcodeviewer", temp_path]
|
||||
|
||||
# Use Popen to not block Blender
|
||||
subprocess.Popen(cmd)
|
||||
|
||||
if operator:
|
||||
operator.report({'INFO'}, f"PrusaSlicer Preview launched")
|
||||
operator.report({'INFO'}, f"PrusaSlicer Previews launched")
|
||||
except Exception as e:
|
||||
if operator: operator.report({'ERROR'}, f"Failed to launch preview: {str(e)}")
|
||||
return 'error'
|
||||
|
||||
return 'ok'
|
||||
|
||||
@register_class
|
||||
class SLICENODE_GcodeToMesh(ExecSliceNode):
|
||||
bl_label = "Gcode Preview"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue