WIP First work towards printer profiles
This commit is contained in:
1 parent
e55f11c5b9
commit
1957d2bb58
18 files changed
+568
-46
No files matched your search
@@ -229,7 +229,7 @@ class CuraPlugin(octoprint.plugin.SlicerPlugin,
|
||||
|
||||
self._save_profile(path, new_profile, allow_overwrite=allow_overwrite)
|
||||
|
||||
def do_slice(self, model_path, machinecode_path=None, profile_path=None, on_progress=None, on_progress_args=None, on_progress_kwargs=None):
|
||||
def do_slice(self, model_path, printer_profile, machinecode_path=None, profile_path=None, on_progress=None, on_progress_args=None, on_progress_kwargs=None):
|
||||
if not profile_path:
|
||||
profile_path = s.get(["default_profile"])
|
||||
if not machinecode_path:
|
||||
@@ -244,7 +244,7 @@ class CuraPlugin(octoprint.plugin.SlicerPlugin,
|
||||
|
||||
self._cura_logger.info("### Slicing %s to %s using profile stored at %s" % (model_path, machinecode_path, profile_path))
|
||||
|
||||
engine_settings = self._convert_to_engine(profile_path)
|
||||
engine_settings = self._convert_to_engine(profile_path, printer_profile)
|
||||
|
||||
executable = s.get(["cura_engine"])
|
||||
if not executable:
|
||||
@@ -385,8 +385,8 @@ class CuraPlugin(octoprint.plugin.SlicerPlugin,
|
||||
with open(path, "wb") as f:
|
||||
yaml.safe_dump(profile, f, default_flow_style=False, indent=" ", allow_unicode=True)
|
||||
|
||||
def _convert_to_engine(self, profile_path):
|
||||
profile = Profile(self._load_profile(profile_path))
|
||||
def _convert_to_engine(self, profile_path, printer_profile):
|
||||
profile = Profile(self._load_profile(profile_path), printer_profile)
|
||||
return profile.convert_to_engine()
|
||||
|
||||
def _sanitize_name(name):
|
||||
|
||||
@@ -515,8 +515,9 @@ class Profile(object):
|
||||
|
||||
return result
|
||||
|
||||
def __init__(self, profile, overrides=None):
|
||||
def __init__(self, profile, printer_profile, overrides=None):
|
||||
self._profile = self.__class__.merge_profile(profile, overrides=overrides)
|
||||
self._printer_profile = printer_profile
|
||||
|
||||
def profile(self):
|
||||
import copy
|
||||
@@ -524,23 +525,22 @@ class Profile(object):
|
||||
|
||||
def get(self, key):
|
||||
if key in ("machine_width", "machine_depth", "machine_center_is_zero"):
|
||||
bedDimensions = s.globalGet(["printerParameters", "bedDimensions"])
|
||||
circular = bedDimensions["circular"] if "circular" in bedDimensions else False
|
||||
radius = bedDimensions["radius"] if "radius" in bedDimensions and bedDimensions["radius"] is not None else 0
|
||||
if key == "machine_width":
|
||||
return radius * 2 if circular else bedDimensions["x"]
|
||||
return self._printer_profile["volume"]["width"]
|
||||
elif key == "machine_depth":
|
||||
return radius * 2 if circular else bedDimensions["y"]
|
||||
return self._printer_profile["volume"]["depth"]
|
||||
elif key == "machine_height":
|
||||
return self._printer_profile["volume"]["height"]
|
||||
elif key == "machine_center_is_zero":
|
||||
return circular
|
||||
return self._printer_profile["volume"]["formFactor"] == "circular"
|
||||
else:
|
||||
return None
|
||||
|
||||
elif key == "extruder_amount":
|
||||
return s.globalGetInt(["printerParameters", "numExtruders"])
|
||||
return self._printer_profile["extruder"]["count"]
|
||||
|
||||
elif key.startswith("extruder_offset_"):
|
||||
extruder_offsets = s.globalGet(["printerParameters", "extruderOffsets"])
|
||||
extruder_offsets = self._printer_profile["extruder"]["offsets"]
|
||||
match = Profile.regex_extruder_offset.match(key)
|
||||
if not match:
|
||||
return 0.0
|
||||
@@ -553,9 +553,13 @@ class Profile(object):
|
||||
return 0.0
|
||||
if number >= len(extruder_offsets):
|
||||
return 0.0
|
||||
if not axis in extruder_offsets[number]:
|
||||
|
||||
if axis == "x":
|
||||
return extruder_offsets[number][0]
|
||||
elif axis == "y":
|
||||
return extruder_offsets[number][1]
|
||||
else:
|
||||
return 0.0
|
||||
return extruder_offsets[number][axis]
|
||||
|
||||
elif key.startswith("filament_diameter"):
|
||||
match = Profile.regex_filament_diameter.match(key)
|
||||
|
||||
Reference in new issue
Block a user