From 74d8329a73a87a2029fb122e1dde0d8b07bd93f8 Mon Sep 17 00:00:00 2001 From: Daid Date: Sun, 29 Apr 2012 14:22:20 +0200 Subject: [PATCH] Fixed positioning when using multiple extruders. Fixed GCode preview for multiple extruders. Removed multiply, depricated because of the project planner, and does not work right with multiple extruders. --- .../geometry/solids/triangle_mesh.py | 2 +- Cura/cura_sf/fabmetheus_utilities/settings.py | 5 ++- .../skeinforge_plugins/craft_plugins/carve.py | 41 ++++++++++++++----- .../skeinforge_plugins/craft_plugins/skirt.py | 2 + Cura/gui/preview3d.py | 15 ++++--- Cura/gui/sliceProgessPanel.py | 3 +- Cura/util/gcodeInterpreter.py | 16 ++++++-- 7 files changed, 60 insertions(+), 24 deletions(-) diff --git a/Cura/cura_sf/fabmetheus_utilities/geometry/solids/triangle_mesh.py b/Cura/cura_sf/fabmetheus_utilities/geometry/solids/triangle_mesh.py index 32398305..550f4006 100644 --- a/Cura/cura_sf/fabmetheus_utilities/geometry/solids/triangle_mesh.py +++ b/Cura/cura_sf/fabmetheus_utilities/geometry/solids/triangle_mesh.py @@ -824,7 +824,7 @@ class TriangleMesh( group.Group ): halfHeight = 0.5 * self.layerHeight self.zoneArrangement = ZoneArrangement(self.layerHeight, self.getTransformedVertexes()) layerTop = self.cornerMaximum.z - halfHeight * 0.5 - z = self.cornerMinimum.z + halfHeight + z = halfHeight layerCount = int((layerTop - z) / self.layerHeight) + 1 while z < layerTop: getLoopLayerAppend(self.loopLayers, layerCount, z).loops = self.getLoopsFromMesh(self.zoneArrangement.getEmptyZ(z)) diff --git a/Cura/cura_sf/fabmetheus_utilities/settings.py b/Cura/cura_sf/fabmetheus_utilities/settings.py index 08ad268d..fa79a29c 100644 --- a/Cura/cura_sf/fabmetheus_utilities/settings.py +++ b/Cura/cura_sf/fabmetheus_utilities/settings.py @@ -113,6 +113,9 @@ def getProfileInformation(): 'SwapYZ': storedSetting("swap_yz"), 'Scale': storedSettingFloat("model_scale"), 'Rotate': storedSettingFloat("model_rotate_base"), + 'CenterX': storedSettingFloat("machine_center_x"), + 'CenterY': storedSettingFloat("machine_center_y"), + 'AlternativeCenterFile': storedSetting("alternative_center"), },'scale': { 'Activate_Scale': "False", 'XY_Plane_Scale_ratio': DEFSET, @@ -171,7 +174,7 @@ def getProfileInformation(): 'Surrounding_Angle_degrees': DEFSET, 'Thread_Sequence_Choice': storedSetting('sequence'), },'multiply': { - 'Activate_Multiply': "True", + 'Activate_Multiply': "False", 'Center_X_mm': storedSettingFloat("machine_center_x"), 'Center_Y_mm': storedSettingFloat("machine_center_y"), 'Number_of_Columns_integer': storedSetting('model_multiply_x'), diff --git a/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/carve.py b/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/carve.py index ae949b3d..b3ad845e 100644 --- a/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/carve.py +++ b/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/carve.py @@ -185,8 +185,11 @@ class CarveRepository: self.flipZ = settings.BooleanSetting().getFromValue('FlipZ', self, False) self.swapXZ = settings.BooleanSetting().getFromValue('SwapXZ', self, False) self.swapYZ = settings.BooleanSetting().getFromValue('SwapYZ', self, False) + self.centerX = settings.FloatSpin().getFromValue(0.0, 'CenterX', self, 1000.0, 0.0) + self.centerY = settings.FloatSpin().getFromValue(0.0, 'CenterY', self, 1000.0, 0.0) self.scale = settings.FloatSpin().getFromValue( 0.1, 'Scale', self, 10.0, 1.0 ) self.rotate = settings.FloatSpin().getFromValue( -180.0, 'Rotate', self, 180.0, 0.0 ) + self.alternativeCenter = settings.StringSetting().getFromValue('AlternativeCenterFile', self, '') def execute(self): @@ -219,16 +222,6 @@ class CarveSkein: mat10 = math.sin(rotate) * scaleX mat11 = math.cos(rotate) * scaleY - minZ = carving.getMinimumZ() - minSize = carving.getCarveCornerMinimum() - maxSize = carving.getCarveCornerMaximum() - for v in carving.vertexes: - v.z -= minZ - v.x -= minSize.x + (maxSize.x - minSize.x) / 2 - v.y -= minSize.y + (maxSize.y - minSize.y) / 2 - #v.x += self.machineCenter.x - #v.y += self.machineCenter.y - for i in xrange(0, len(carving.vertexes)): x = carving.vertexes[i].x y = carving.vertexes[i].y @@ -242,6 +235,34 @@ class CarveSkein: x * mat10 + y * mat11, z * scaleZ) + if repository.alternativeCenter.value != '': + carving2 = svg_writer.getCarving(repository.alternativeCenter.value) + for i in xrange(0, len(carving2.vertexes)): + x = carving2.vertexes[i].x + y = carving2.vertexes[i].y + z = carving2.vertexes[i].z + if swapXZ: + x, z = z, x + if swapYZ: + y, z = z, y + carving2.vertexes[i] = Vector3( + x * mat00 + y * mat01, + x * mat10 + y * mat11, + z * scaleZ) + minZ = carving2.getMinimumZ() + minSize = carving2.getCarveCornerMinimum() + maxSize = carving2.getCarveCornerMaximum() + else: + minZ = carving.getMinimumZ() + minSize = carving.getCarveCornerMinimum() + maxSize = carving.getCarveCornerMaximum() + for v in carving.vertexes: + v.z -= minZ + v.x -= minSize.x + (maxSize.x - minSize.x) / 2 + v.y -= minSize.y + (maxSize.y - minSize.y) / 2 + v.x += repository.centerX.value + v.y += repository.centerY.value + layerHeight = repository.layerHeight.value edgeWidth = repository.edgeWidth.value carving.setCarveLayerHeight(layerHeight) diff --git a/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/skirt.py b/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/skirt.py index 4a87d471..51f3549c 100644 --- a/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/skirt.py +++ b/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/skirt.py @@ -171,6 +171,8 @@ class SkirtSkein: def addSkirt(self, z): 'At skirt at z to gcode output.' + if len(self.outsetLoops) < 1 or len(self.outsetLoops[0]) < 1: + return self.setSkirtFeedFlowTemperature() self.distanceFeedRate.addLine('()') oldTemperature = self.oldTemperatureInput diff --git a/Cura/gui/preview3d.py b/Cura/gui/preview3d.py index ad2f5f0d..f905d0f4 100644 --- a/Cura/gui/preview3d.py +++ b/Cura/gui/preview3d.py @@ -93,12 +93,11 @@ class previewPanel(wx.Panel): self.toolbar2.AddSeparator() # Multiply - self.mulXadd = toolbarUtil.NormalButton(self.toolbar2, self.OnMulXAddClick, 'object-mul-x-add.png', 'Increase number of models on X axis') - self.mulXsub = toolbarUtil.NormalButton(self.toolbar2, self.OnMulXSubClick, 'object-mul-x-sub.png', 'Decrease number of models on X axis') - self.mulYadd = toolbarUtil.NormalButton(self.toolbar2, self.OnMulYAddClick, 'object-mul-y-add.png', 'Increase number of models on Y axis') - self.mulYsub = toolbarUtil.NormalButton(self.toolbar2, self.OnMulYSubClick, 'object-mul-y-sub.png', 'Decrease number of models on Y axis') - - self.toolbar2.AddSeparator() + #self.mulXadd = toolbarUtil.NormalButton(self.toolbar2, self.OnMulXAddClick, 'object-mul-x-add.png', 'Increase number of models on X axis') + #self.mulXsub = toolbarUtil.NormalButton(self.toolbar2, self.OnMulXSubClick, 'object-mul-x-sub.png', 'Decrease number of models on X axis') + #self.mulYadd = toolbarUtil.NormalButton(self.toolbar2, self.OnMulYAddClick, 'object-mul-y-add.png', 'Increase number of models on Y axis') + #self.mulYsub = toolbarUtil.NormalButton(self.toolbar2, self.OnMulYSubClick, 'object-mul-y-sub.png', 'Decrease number of models on Y axis') + #self.toolbar2.AddSeparator() # Rotate self.rotateReset = toolbarUtil.NormalButton(self.toolbar2, self.OnRotateReset, 'object-rotate.png', 'Reset model rotation') @@ -623,8 +622,8 @@ class PreviewGLCanvas(glcanvas.GLCanvas): glFlush() def drawModel(self, obj): - multiX = int(profile.getProfileSetting('model_multiply_x')) - multiY = int(profile.getProfileSetting('model_multiply_y')) + multiX = 1 #int(profile.getProfileSetting('model_multiply_x')) + multiY = 1 #int(profile.getProfileSetting('model_multiply_y')) modelScale = profile.getProfileSettingFloat('model_scale') modelSize = (obj.mesh.getMaximum() - obj.mesh.getMinimum()) * modelScale glPushMatrix() diff --git a/Cura/gui/sliceProgessPanel.py b/Cura/gui/sliceProgessPanel.py index 7c1a2df0..bb83266b 100644 --- a/Cura/gui/sliceProgessPanel.py +++ b/Cura/gui/sliceProgessPanel.py @@ -68,6 +68,7 @@ class sliceProgessPanel(wx.Panel): profile.putProfileSetting('skirt_line_count', '0') profile.putProfileSetting('machine_center_x', profile.getProfileSettingFloat('machine_center_x') + float(profile.getPreference('extruder_offset_x%d' % (idx)))) profile.putProfileSetting('machine_center_y', profile.getProfileSettingFloat('machine_center_y') + float(profile.getPreference('extruder_offset_y%d' % (idx)))) + profile.putProfileSetting('alternative_center', self.filelist[0]) if len(self.filelist) > 1: profile.putProfileSetting('add_start_end_gcode', 'False') profile.putProfileSetting('gcode_extension', 'multi_extrude_tmp') @@ -105,7 +106,7 @@ class sliceProgessPanel(wx.Panel): status += " Print time: %02d:%02d" % (int(result.gcode.totalMoveTimeMinute / 60), int(result.gcode.totalMoveTimeMinute % 60)) cost = result.gcode.calculateCost() if cost != False: - status += "Cost: %s" % (cost) + status += " Cost: %s" % (cost) self.statusText.SetLabel(status) if exporer.hasExporer(): self.openFileLocationButton = wx.Button(self, -1, "Open file location") diff --git a/Cura/util/gcodeInterpreter.py b/Cura/util/gcodeInterpreter.py index 7e83d3f4..a84f1ec5 100644 --- a/Cura/util/gcodeInterpreter.py +++ b/Cura/util/gcodeInterpreter.py @@ -56,6 +56,7 @@ class gcode(): currentE = 0.0 totalExtrusion = 0.0 maxExtrusion = 0.0 + currentExtruder = 0 totalMoveTimeMinute = 0.0 scale = 1.0 posAbs = True @@ -90,6 +91,15 @@ class gcode(): if pathType != "CUSTOM": startCodeDone = True line = line[0:line.find(';')] + T = self.getCodeInt(line, 'T') + if T is not None: + if currentExtruder > 0: + posOffset.x += float(profile.getPreference('extruder_offset_x%d' % (currentExtruder))) + posOffset.y += float(profile.getPreference('extruder_offset_y%d' % (currentExtruder))) + currentExtruder = T + if currentExtruder > 0: + posOffset.x -= float(profile.getPreference('extruder_offset_x%d' % (currentExtruder))) + posOffset.y -= float(profile.getPreference('extruder_offset_y%d' % (currentExtruder))) G = self.getCodeInt(line, 'G') if G is not None: @@ -102,17 +112,17 @@ class gcode(): oldPos = pos.copy() if x is not None: if posAbs: - pos.x = x * scale + pos.x = x * scale + posOffset.x else: pos.x += x * scale if y is not None: if posAbs: - pos.y = y * scale + pos.y = y * scale + posOffset.y else: pos.y += y * scale if z is not None: if posAbs: - pos.z = z * scale + pos.z = z * scale + posOffset.z else: pos.z += z * scale #Check if we have a new layer. -- 2.30.2