Merge pull request #19029 from Ultimaker/CURA-11777-yeet-sketch-to-makerbot

Cura 11777 yeet sketch to makerbot
This commit is contained in:
HellAholic 2024-05-17 10:43:55 +02:00 committed by GitHub
commit 328af077e5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 12793 additions and 31 deletions

View File

@ -422,7 +422,8 @@ class NetworkedPrinterOutputDevice(PrinterOutputDevice):
_PRINTER_TYPE_NAME = { _PRINTER_TYPE_NAME = {
"fire_e": "ultimaker_method", "fire_e": "ultimaker_method",
"lava_f": "ultimaker_methodx", "lava_f": "ultimaker_methodx",
"magma_10": "ultimaker_methodxl" "magma_10": "ultimaker_methodxl",
"sketch": "ultimaker_sketch"
} }
if printer_type in _PRINTER_TYPE_NAME: if printer_type in _PRINTER_TYPE_NAME:
return _PRINTER_TYPE_NAME[printer_type] return _PRINTER_TYPE_NAME[printer_type]

View File

@ -1,9 +1,8 @@
# Copyright (c) 2023 UltiMaker # Copyright (c) 2023 UltiMaker
# Cura is released under the terms of the LGPLv3 or higher. # Cura is released under the terms of the LGPLv3 or higher.
from io import StringIO, BufferedIOBase from io import StringIO, BufferedIOBase
import json import json
from typing import cast, List, Optional, Dict from typing import cast, List, Optional, Dict, Tuple
from zipfile import BadZipFile, ZipFile, ZIP_DEFLATED from zipfile import BadZipFile, ZipFile, ZIP_DEFLATED
import pyDulcificum as du import pyDulcificum as du
@ -39,16 +38,27 @@ class MakerbotWriter(MeshWriter):
suffixes=["makerbot"] suffixes=["makerbot"]
) )
) )
MimeTypeDatabase.addMimeType(
MimeType(
name="application/x-makerbot-sketch",
comment="Makerbot Toolpath Package",
suffixes=["makerbot"]
)
)
_PNG_FORMATS = [ _PNG_FORMAT = [
{"prefix": "isometric_thumbnail", "width": 120, "height": 120}, {"prefix": "isometric_thumbnail", "width": 120, "height": 120},
{"prefix": "isometric_thumbnail", "width": 320, "height": 320}, {"prefix": "isometric_thumbnail", "width": 320, "height": 320},
{"prefix": "isometric_thumbnail", "width": 640, "height": 640}, {"prefix": "isometric_thumbnail", "width": 640, "height": 640},
{"prefix": "thumbnail", "width": 90, "height": 90},
]
_PNG_FORMAT_METHOD = [
{"prefix": "thumbnail", "width": 140, "height": 106}, {"prefix": "thumbnail", "width": 140, "height": 106},
{"prefix": "thumbnail", "width": 212, "height": 300}, {"prefix": "thumbnail", "width": 212, "height": 300},
{"prefix": "thumbnail", "width": 960, "height": 1460}, {"prefix": "thumbnail", "width": 960, "height": 1460},
{"prefix": "thumbnail", "width": 90, "height": 90},
] ]
_META_VERSION = "3.0.0" _META_VERSION = "3.0.0"
# must be called from the main thread because of OpenGL # must be called from the main thread because of OpenGL
@ -74,6 +84,7 @@ class MakerbotWriter(MeshWriter):
return None return None
def write(self, stream: BufferedIOBase, nodes: List[SceneNode], mode=MeshWriter.OutputMode.BinaryMode) -> bool: def write(self, stream: BufferedIOBase, nodes: List[SceneNode], mode=MeshWriter.OutputMode.BinaryMode) -> bool:
metadata, file_format = self._getMeta(nodes)
if mode != MeshWriter.OutputMode.BinaryMode: if mode != MeshWriter.OutputMode.BinaryMode:
Logger.log("e", "MakerbotWriter does not support text mode.") Logger.log("e", "MakerbotWriter does not support text mode.")
self.setInformation(catalog.i18nc("@error:not supported", "MakerbotWriter does not support text mode.")) self.setInformation(catalog.i18nc("@error:not supported", "MakerbotWriter does not support text mode."))
@ -92,14 +103,20 @@ class MakerbotWriter(MeshWriter):
gcode_text_io = StringIO() gcode_text_io = StringIO()
success = gcode_writer.write(gcode_text_io, None) success = gcode_writer.write(gcode_text_io, None)
filename, filedata = "", ""
# Writing the g-code failed. Then I can also not write the gzipped g-code. # Writing the g-code failed. Then I can also not write the gzipped g-code.
if not success: if not success:
self.setInformation(gcode_writer.getInformation()) self.setInformation(gcode_writer.getInformation())
return False return False
match file_format:
json_toolpaths = du.gcode_2_miracle_jtp(gcode_text_io.getvalue()) case "application/x-makerbot-sketch":
metadata = self._getMeta(nodes) filename, filedata = "print.gcode", gcode_text_io.getvalue()
self._PNG_FORMATS = self._PNG_FORMAT
case "application/x-makerbot":
filename, filedata = "print.jsontoolpath", du.gcode_2_miracle_jtp(gcode_text_io.getvalue())
self._PNG_FORMATS = self._PNG_FORMAT + self._PNG_FORMAT_METHOD
case _:
raise Exception("Unsupported Mime type")
png_files = [] png_files = []
for png_format in self._PNG_FORMATS: for png_format in self._PNG_FORMATS:
@ -116,7 +133,7 @@ class MakerbotWriter(MeshWriter):
try: try:
with ZipFile(stream, "w", compression=ZIP_DEFLATED) as zip_stream: with ZipFile(stream, "w", compression=ZIP_DEFLATED) as zip_stream:
zip_stream.writestr("meta.json", json.dumps(metadata, indent=4)) zip_stream.writestr("meta.json", json.dumps(metadata, indent=4))
zip_stream.writestr("print.jsontoolpath", json_toolpaths) zip_stream.writestr(filename, filedata)
for png_file in png_files: for png_file in png_files:
file, data = png_file["file"], png_file["data"] file, data = png_file["file"], png_file["data"]
zip_stream.writestr(file, data) zip_stream.writestr(file, data)
@ -127,7 +144,7 @@ class MakerbotWriter(MeshWriter):
return True return True
def _getMeta(self, root_nodes: List[SceneNode]) -> Dict[str, any]: def _getMeta(self, root_nodes: List[SceneNode]) -> Tuple[Dict[str, any], str]:
application = CuraApplication.getInstance() application = CuraApplication.getInstance()
machine_manager = application.getMachineManager() machine_manager = application.getMachineManager()
global_stack = machine_manager.activeMachine global_stack = machine_manager.activeMachine
@ -143,7 +160,9 @@ class MakerbotWriter(MeshWriter):
nodes.append(node) nodes.append(node)
meta = dict() meta = dict()
# This is a bit of a "hack", the mime type should be passed through with the export writer but
# since this is not the case we get the mime type from the global stack instead
file_format = global_stack.definition.getMetaDataEntry("file_formats")
meta["bot_type"] = global_stack.definition.getMetaDataEntry("reference_machine_id") meta["bot_type"] = global_stack.definition.getMetaDataEntry("reference_machine_id")
bounds: Optional[AxisAlignedBox] = None bounds: Optional[AxisAlignedBox] = None
@ -155,7 +174,8 @@ class MakerbotWriter(MeshWriter):
bounds = node_bounds bounds = node_bounds
else: else:
bounds = bounds + node_bounds bounds = bounds + node_bounds
if file_format == "application/x-makerbot-sketch":
bounds = None
if bounds is not None: if bounds is not None:
meta["bounding_box"] = { meta["bounding_box"] = {
"x_min": bounds.left, "x_min": bounds.left,
@ -196,7 +216,7 @@ class MakerbotWriter(MeshWriter):
meta["extruder_temperature"] = materials_temps[0] meta["extruder_temperature"] = materials_temps[0]
meta["extruder_temperatures"] = materials_temps meta["extruder_temperatures"] = materials_temps
meta["model_counts"] = [{"count": 1, "name": node.getName()} for node in nodes] meta["model_counts"] = [{"count": len(nodes), "name": "instance0"}]
tool_types = [extruder.variant.getMetaDataEntry("reference_extruder_id") for extruder in extruders] tool_types = [extruder.variant.getMetaDataEntry("reference_extruder_id") for extruder in extruders]
meta["tool_type"] = tool_types[0] meta["tool_type"] = tool_types[0]
@ -205,12 +225,11 @@ class MakerbotWriter(MeshWriter):
meta["version"] = MakerbotWriter._META_VERSION meta["version"] = MakerbotWriter._META_VERSION
meta["preferences"] = dict() meta["preferences"] = dict()
for node in nodes: bounds = application.getBuildVolume().getBoundingBox()
bounds = node.getBoundingBox() meta["preferences"]["instance0"] = {
meta["preferences"][str(node.getName())] = { "machineBounds": [bounds.right, bounds.back, bounds.left, bounds.front] if bounds is not None else None,
"machineBounds": [bounds.right, bounds.back, bounds.left, bounds.front] if bounds is not None else None, "printMode": CuraApplication.getInstance().getIntentManager().currentIntentCategory,
"printMode": CuraApplication.getInstance().getIntentManager().currentIntentCategory, }
}
meta["miracle_config"] = {"gaggles": {str(node.getName()): {} for node in nodes}} meta["miracle_config"] = {"gaggles": {str(node.getName()): {} for node in nodes}}
@ -245,7 +264,7 @@ class MakerbotWriter(MeshWriter):
# platform_temperature # platform_temperature
# total_commands # total_commands
return meta return meta, file_format
def meterToMillimeter(value: float) -> float: def meterToMillimeter(value: float) -> float:

View File

@ -11,14 +11,23 @@ catalog = i18nCatalog("cura")
def getMetaData(): def getMetaData():
file_extension = "makerbot" file_extension = "makerbot"
return { return {
"mesh_writer": { "mesh_writer":
"output": [{ {
"extension": file_extension, "output": [
"description": catalog.i18nc("@item:inlistbox", "Makerbot Printfile"), {
"mime_type": "application/x-makerbot", "extension": file_extension,
"mode": MakerbotWriter.MakerbotWriter.OutputMode.BinaryMode, "description": catalog.i18nc("@item:inlistbox", "Makerbot Printfile"),
}], "mime_type": "application/x-makerbot",
} "mode": MakerbotWriter.MakerbotWriter.OutputMode.BinaryMode,
},
{
"extension": file_extension,
"description": catalog.i18nc("@item:inlistbox", "Makerbot Sketch Printfile"),
"mime_type": "application/x-makerbot-sketch",
"mode": MakerbotWriter.MakerbotWriter.OutputMode.BinaryMode,
}
]
},
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 185 KiB

View File

@ -331,7 +331,7 @@ class CloudOutputDevice(UltimakerNetworkedPrinterOutputDevice):
return False return False
[printer, *_] = self._printers [printer, *_] = self._printers
return printer.type in ("MakerBot Method X", "MakerBot Method XL") return printer.type in ("MakerBot Method X", "MakerBot Method XL", "MakerBot Sketch")
@pyqtProperty(bool, notify=_cloudClusterPrintersChanged) @pyqtProperty(bool, notify=_cloudClusterPrintersChanged)
def supportsPrintJobActions(self) -> bool: def supportsPrintJobActions(self) -> bool:

View File

@ -2,5 +2,6 @@
"ultimaker_method": "MakerBot Method", "ultimaker_method": "MakerBot Method",
"ultimaker_methodx": "MakerBot Method X", "ultimaker_methodx": "MakerBot Method X",
"ultimaker_methodxl": "MakerBot Method XL", "ultimaker_methodxl": "MakerBot Method XL",
"ultimaker_factor4": "Ultimaker Factor 4" "ultimaker_factor4": "Ultimaker Factor 4",
"ultimaker_sketch": "MakerBot Sketch"
} }

View File

@ -0,0 +1,259 @@
{
"version": 2,
"name": "UltiMaker Sketch",
"inherits": "ultimaker",
"metadata":
{
"visible": true,
"author": "Ultimaker",
"manufacturer": "Ultimaker B.V.",
"file_formats": "application/x-makerbot-sketch",
"platform": "ultimaker_sketch_platform.obj",
"exclude_materials": [
"dsm_175_novamidid1030cf",
"Essentium_175_UltrafuseZPCTG",
"imade3d_petg_175",
"imade3d_pla_175",
"imade3d_petg_green",
"imade3d_pla_green",
"imade3d_petg_pink",
"imade3d_pla_pink",
"chromatik_pla",
"3D-Fuel_PLA_PRO_Black",
"3D-Fuel_PLA_SnapSupport",
"bestfilament_abs_skyblue",
"bestfilament_petg_orange",
"bestfilament_pla_green",
"dsm_arnitel2045_175",
"dsm_novamid1070_175",
"emotiontech_abs",
"emotiontech_absx",
"emotiontech_acetate",
"emotiontech_asax",
"emotiontech_bvoh",
"emotiontech_copa",
"emotiontech_hips",
"emotiontech_nylon_1030",
"emotiontech_nylon_1030cf",
"emotiontech_nylon_1070",
"emotiontech_pc",
"emotiontech_pekk",
"emotiontech_petg",
"emotiontech_pla",
"emotiontech_pla_hr_870",
"emotiontech_pva-m",
"emotiontech_pva-s",
"emotiontech_tpu98a",
"eryone_petg",
"eryone_pla",
"eryone_pla_glow",
"eryone_pla_matte",
"eryone_pla_wood",
"eryone_tpu",
"eSUN_PETG_Black",
"eSUN_PETG_Grey",
"eSUN_PETG_Purple",
"eSUN_PLA_PRO_Black",
"eSUN_PLA_PRO_Grey",
"eSUN_PLA_PRO_Purple",
"eSUN_PLA_PRO_White",
"Extrudr_GreenTECPro_Anthracite_175",
"Extrudr_GreenTECPro_Black_175",
"Extrudr_GreenTECPro_Blue_175",
"Extrudr_GreenTECPro_Nature_175",
"Extrudr_GreenTECPro_Red_175",
"Extrudr_GreenTECPro_Silver_175",
"Extrudr_GreenTECPro_White_175",
"fabtotum_abs",
"fabtotum_nylon",
"fabtotum_pla",
"fabtotum_tpu",
"fdplast_abs_tomato",
"fdplast_petg_gray",
"fdplast_pla_olive",
"filo3d_pla",
"filo3d_pla_green",
"filo3d_pla_red",
"generic_asa_175",
"generic_abs_175",
"generic_absr_175",
"generic_bvoh_175",
"generic_cpe_175",
"generic_cffpa_175",
"generic_hips_175",
"generic_nylon_175",
"generic_pc_175",
"generic_petg_175",
"generic_pva_175",
"generic_rapidrinse_175",
"generic_sr30_175",
"generic_tpu_175",
"goofoo_abs",
"goofoo_asa",
"goofoo_bronze_pla",
"goofoo_emarble_pla",
"goofoo_esilk_pla",
"goofoo_hips",
"goofoo_pa",
"goofoo_pa_cf",
"goofoo_pc",
"goofoo_peek",
"goofoo_petg",
"goofoo_pla",
"goofoo_pva",
"goofoo_tpe_83a",
"goofoo_tpu_87a",
"goofoo_tpu_95a",
"goofoo_wood_pla",
"ideagen3D_ToughPLA",
"imade3d_petg_175",
"imade3d_pla_175",
"innofill_innoflex60_175",
"layer_one_black_pla",
"layer_one_dark_gray_pla",
"layer_one_white_pla",
"leapfrog_abs_natural",
"leapfrog_epla_natural",
"leapfrog_pva_natural",
"polyflex_pla",
"polymax_pla",
"polyplus_pla",
"polywood_pla",
"redd_abs",
"redd_asa",
"redd_hips",
"redd_nylon",
"redd_petg",
"redd_pla",
"redd_tpe",
"tizyx_abs",
"tizyx_flex",
"tizyx_petg",
"tizyx_pla",
"tizyx_pla_bois",
"tizyx_pva",
"verbatim_bvoh_175",
"Vertex_Delta_ABS",
"Vertex_Delta_PET",
"Vertex_Delta_PLA",
"Vertex_Delta_PLA_Glitter",
"Vertex_Delta_PLA_Mat",
"Vertex_Delta_PLA_Satin",
"Vertex_Delta_PLA_Wood",
"Vertex_Delta_TPU",
"volumic_abs_ultra",
"volumic_arma_ultra",
"volumic_asa_ultra",
"volumic_br80_ultra",
"volumic_bumper_ultra",
"volumic_cu80_ultra",
"volumic_flex93_ultra",
"volumic_medical_ultra",
"volumic_nylon_ultra",
"volumic_pekk_carbone",
"volumic_petgcarbone_ultra",
"volumic_petg_ultra",
"volumic_pla_ultra",
"volumic_pp_ultra",
"volumic_strong_ultra",
"volumic_support_ultra",
"xyzprinting_abs",
"xyzprinting_antibact_pla",
"xyzprinting_carbon_fiber",
"xyzprinting_colorinkjet_pla",
"xyzprinting_flexible",
"xyzprinting_metallic_pla",
"xyzprinting_nylon",
"xyzprinting_pahtcf15",
"xyzprinting_pc",
"xyzprinting_petcf15",
"xyzprinting_petg",
"xyzprinting_pla",
"xyzprinting_ppgf30",
"xyzprinting_tough_pla",
"xyzprinting_tpu",
"zyyx_pro_flex",
"zyyx_pro_pla",
"octofiber_pla",
"fiberlogy_hd_pla"
],
"has_machine_quality": true,
"has_materials": true,
"has_variants": false,
"machine_extruder_trains": { "0": "ultimaker_sketch_extruder" },
"platform_offset": [
0,
0,
0
],
"platform_texture": "MakerbotSketch.png",
"preferred_quality_type": "draft",
"preferred_variant_name": "0.4mm",
"reference_machine_id": "sketch",
"supports_network_connection": true,
"supports_usb_connection": false,
"variant_definition": "ultimaker_sketch",
"variants_name": "Extruder",
"weight": -1
},
"overrides":
{
"acceleration_enabled": { "value": false },
"adhesion_type": { "value": "'raft'" },
"brim_width": { "value": "3" },
"cool_fan_speed": { "value": "100" },
"extruder_prime_pos_abs": { "default_value": true },
"gantry_height": { "value": "60" },
"infill_overlap": { "value": 15 },
"infill_pattern": { "value": "'zigzag' if infill_sparse_density > 80 else 'triangles'" },
"infill_sparse_density": { "value": 15 },
"jerk_enabled": { "value": false },
"layer_start_x": { "value": "sum(extruderValues('machine_extruder_start_pos_x')) / len(extruderValues('machine_extruder_start_pos_x'))" },
"layer_start_y": { "value": "sum(extruderValues('machine_extruder_start_pos_y')) / len(extruderValues('machine_extruder_start_pos_y'))" },
"machine_center_is_zero": { "default_value": true },
"machine_depth": { "default_value": 150 },
"machine_end_gcode": { "default_value": "M107; Disable Fan; \n; End of print; \n; End GCode\nM104 S0 T0; Set Toolhead Temp to 0\nM140 S0 T0; Set Platform Temp to 0\nG162 Z F1800; Move to max axes position\nG28 X Y; Home\nM652; Turn off back fan\nM132 X Y Z A B; Set Home Position\nG91; Use Relative Positioning\nM18; Disable Axes\n\n" },
"machine_extruder_count": { "default_value": 1 },
"machine_gcode_flavor": { "default_value": "Griffin" },
"machine_heated_bed": { "default_value": true },
"machine_height": { "default_value": 150 },
"machine_max_feedrate_x": { "default_value": 300 },
"machine_max_feedrate_y": { "default_value": 300 },
"machine_max_feedrate_z": { "default_value": 40 },
"machine_min_cool_heat_time_window": { "value": "15" },
"machine_name": { "default_value": "UltiMaker Sketch" },
"machine_nozzle_cool_down_speed": { "default_value": 0.8 },
"machine_nozzle_heat_up_speed": { "default_value": 1.4 },
"machine_start_gcode": { "default_value": "M140 S50 T0; Set Platform Temp\nM104 S220 T0; Set Extruder Temp\nG90; Use Absolute Positioning\nG28; Home\nM132 X Y Z A B; Set Current Position to Home\nG161 X Y F3300; Move to min axes positions\nM7 T0; Wait For Platform to Heat\nM6 T0; Wait For Extruders to Heat\nM651; Turn on back fan\nM907 X100 Y100 Z40 A80 B20; Set Stepper Currents\nM106; Enable Cooling Fan\n; Purge Line\nG92 E0; Reset Extruder Axis Position\nG1 X-26.18 Y-75.90 Z0.200 F420\nG1 X26.18 Y-75.90 E10\nG92 E0; Reset Extruder Axis Position\n; Start GCode\n" },
"machine_width": { "default_value": 150 },
"material_diameter": { "default_value": 1.75 },
"material_flow": { "default_value": 109 },
"multiple_mesh_overlap": { "value": "0" },
"optimize_wall_printing_order": { "value": "True" },
"prime_blob_enable":
{
"default_value": true,
"enabled": true,
"value": "resolveOrValue('print_sequence') != 'one_at_a_time'"
},
"raft_margin": { "value": "5" },
"retraction_amount": { "value": "5.5" },
"retraction_prime_speed": { "value": "15" },
"retraction_speed": { "value": "25" },
"speed_print": { "value": 60 },
"speed_support": { "value": "0.7 * speed_print" },
"speed_support_interface": { "value": "speed_topbottom" },
"speed_topbottom": { "value": "0.7 * speed_print" },
"speed_travel": { "value": 80 },
"speed_wall": { "value": "0.7 * speed_print" },
"speed_wall_0": { "value": "0.5 * speed_print " },
"speed_wall_x": { "value": "speed_wall" },
"speed_z_hop": { "value": 7 },
"support_angle": { "value": "45" },
"top_bottom_thickness": { "value": "4 * layer_height" },
"travel_avoid_distance": { "value": "machine_nozzle_tip_outer_diameter / 2 * 1.5" },
"wall_0_inset": { "value": "0" },
"wall_thickness": { "value": "2 * machine_nozzle_size" },
"zig_zaggify_infill": { "value": "gradual_infill_steps == 0" }
}
}

View File

@ -0,0 +1,22 @@
{
"version": 2,
"name": "Extruder",
"inherits": "fdmextruder",
"metadata":
{
"machine": "ultimaker_sketch",
"position": "0"
},
"overrides":
{
"extruder_nr":
{
"default_value": 0,
"maximum_value": "1"
},
"machine_nozzle_offset_x": { "default_value": 0 },
"machine_nozzle_offset_y": { "default_value": 0 },
"machine_nozzle_size": { "default_value": 0.4 },
"material_diameter": { "default_value": 1.75 }
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,14 @@
[general]
definition = ultimaker_sketch
name = Fast
version = 4
[metadata]
material = generic_pla_175
quality_type = draft
setting_version = 23
type = quality
weight = -2
[values]

View File

@ -0,0 +1,14 @@
[general]
definition = ultimaker_sketch
name = Fast
version = 4
[metadata]
material = generic_tough_pla_175
quality_type = draft
setting_version = 23
type = quality
weight = -2
[values]

View File

@ -0,0 +1,15 @@
[general]
definition = ultimaker_sketch
name = Fast
version = 4
[metadata]
global_quality = True
quality_type = draft
setting_version = 23
type = quality
weight = -2
[values]
layer_height = 0.2

View File

@ -0,0 +1,15 @@
[general]
definition = ultimaker_sketch
name = 0.4mm
version = 4
[metadata]
hardware_type = nozzle
reference_extruder_id = sketch_extruder
setting_version = 23
type = variant
[values]
machine_nozzle_id = 0.4mm
machine_nozzle_size = 0.4