From e24262f503b7deb1d779dd3be7ef9edb14927a53 Mon Sep 17 00:00:00 2001 From: daid Date: Wed, 4 Dec 2013 10:18:53 +0100 Subject: [PATCH] Make sure the print fits on the bed with dual-extrusion-support. --- Cura/gui/sceneView.py | 4 +++- Cura/util/objectScene.py | 7 ++++++- Cura/util/profile.py | 10 ++++++++++ Cura/util/sliceEngine.py | 6 +++--- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/Cura/gui/sceneView.py b/Cura/gui/sceneView.py index c25cbc90..c7ad9c85 100644 --- a/Cura/gui/sceneView.py +++ b/Cura/gui/sceneView.py @@ -611,7 +611,7 @@ class SceneView(openglGui.glGuiPanel): def _selectObject(self, obj, zoom = True): if obj != self._selectedObj: self._selectedObj = obj - self.updateProfileToControls() + self.updateModelSettingsToControls() self.updateToolButtons() if zoom and obj is not None: newViewPos = numpy.array([obj.getPosition()[0], obj.getPosition()[1], obj.getSize()[2] / 2]) @@ -634,7 +634,9 @@ class SceneView(openglGui.glGuiPanel): self._objColors[2] = profile.getPreferenceColour('model_colour3') self._objColors[3] = profile.getPreferenceColour('model_colour4') self._scene.updateMachineDimensions() + self.updateModelSettingsToControls() + def updateModelSettingsToControls(self): if self._selectedObj is not None: scale = self._selectedObj.getScale() size = self._selectedObj.getSize() diff --git a/Cura/util/objectScene.py b/Cura/util/objectScene.py index 63b1d0ed..b229a709 100644 --- a/Cura/util/objectScene.py +++ b/Cura/util/objectScene.py @@ -90,6 +90,7 @@ class Scene(object): self._sizeOffsets = numpy.array([0.0,0.0], numpy.float32) self._machineSize = numpy.array([100,100,100], numpy.float32) self._headSizeOffsets = numpy.array([18.0,18.0], numpy.float32) + self._minExtruderCount = None self._extruderOffset = [numpy.array([0,0], numpy.float32)] * 4 #Print order variables @@ -107,14 +108,18 @@ class Scene(object): # Size offsets are offsets caused by brim, skirt, etc. def updateSizeOffsets(self, force=False): newOffsets = numpy.array(profile.calculateObjectSizeOffsets(), numpy.float32) - if not force and numpy.array_equal(self._sizeOffsets, newOffsets): + minExtruderCount = profile.minimalExtruderCount() + if not force and numpy.array_equal(self._sizeOffsets, newOffsets) and self._minExtruderCount == minExtruderCount: return self._sizeOffsets = newOffsets + self._minExtruderCount = minExtruderCount extends = [numpy.array([[-newOffsets[0],-newOffsets[1]],[ newOffsets[0],-newOffsets[1]],[ newOffsets[0], newOffsets[1]],[-newOffsets[0], newOffsets[1]]], numpy.float32)] for n in xrange(1, 4): headOffset = numpy.array([[0, 0], [-profile.getMachineSettingFloat('extruder_offset_x%d' % (n)), -profile.getMachineSettingFloat('extruder_offset_y%d' % (n))]], numpy.float32) extends.append(polygon.minkowskiHull(extends[n-1], headOffset)) + if minExtruderCount > 1: + extends[0] = extends[1] for obj in self._objectList: obj.setPrintAreaExtends(extends[len(obj._meshList) - 1]) diff --git a/Cura/util/profile.py b/Cura/util/profile.py index a2f0255a..d6239dc4 100644 --- a/Cura/util/profile.py +++ b/Cura/util/profile.py @@ -895,6 +895,16 @@ def getMachineSizePolygons(): ret.append(numpy.array([[ size[0]/2, size[1]/2],[ size[0]/2-w-2, size[1]/2], [ size[0]/2-w, size[1]/2-h],[ size[0]/2, size[1]/2-h]], numpy.float32)) return ret +#returns the number of extruders minimal used. Normally this returns 1, but with dual-extrusion support material it returns 2 +def minimalExtruderCount(): + if int(getMachineSetting('extruder_amount')) < 2: + return 1 + if getProfileSetting('support') == 'None': + return 1 + if getProfileSetting('support_dual_extrusion') == 'Second extruder': + return 2 + return 1 + ######################################################### ## Alteration file functions ######################################################### diff --git a/Cura/util/sliceEngine.py b/Cura/util/sliceEngine.py index 9cd8fc31..87c539fe 100644 --- a/Cura/util/sliceEngine.py +++ b/Cura/util/sliceEngine.py @@ -117,8 +117,8 @@ class Slicer(object): for obj in scene.objects(): if scene.checkPlatform(obj): extruderCount = max(extruderCount, len(obj._meshList)) - if profile.getProfileSetting('support_dual_extrusion') == 'Second extruder': - extruderCount = max(extruderCount, 2) + + extruderCount = max(extruderCount, profile.minimalExtruderCount()) commandList = [getEngineFilename(), '-vv'] for k, v in self._engineSettings(extruderCount).iteritems(): @@ -280,7 +280,7 @@ class Slicer(object): 'supportLineDistance': int(100 * profile.calculateEdgeWidth() * 1000 / profile.getProfileSettingFloat('support_fill_rate')) if profile.getProfileSettingFloat('support_fill_rate') > 0 else -1, 'supportXYDistance': int(1000 * profile.getProfileSettingFloat('support_xy_distance')), 'supportZDistance': int(1000 * profile.getProfileSettingFloat('support_z_distance')), - 'supportExtruder': 0 if profile.getProfileSetting('support_dual_extrusion') == 'First extruder' else (1 if profile.getProfileSetting('support_dual_extrusion') == 'Second extruder' else -1), + 'supportExtruder': 0 if profile.getProfileSetting('support_dual_extrusion') == 'First extruder' else (1 if profile.getProfileSetting('support_dual_extrusion') == 'Second extruder' and profile.minimalExtruderCount() > 1 else -1), 'retractionAmount': int(profile.getProfileSettingFloat('retraction_amount') * 1000) if profile.getProfileSetting('retraction_enable') == 'True' else 0, 'retractionSpeed': int(profile.getProfileSettingFloat('retraction_speed')), 'retractionMinimalDistance': int(profile.getProfileSettingFloat('retraction_min_travel') * 1000), -- 2.30.2