From: daid303 Date: Tue, 8 Jan 2013 09:01:41 +0000 (+0100) Subject: Fix scale with new matrix mode, X-Git-Tag: 13.03~124 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=2b107c8b4e0f9eba3eba8d57f168cf7ae3e50102;p=cura.git Fix scale with new matrix mode, --- diff --git a/Cura/gui/sliceProgessPanel.py b/Cura/gui/sliceProgessPanel.py index 7d76d5ed..47709882 100644 --- a/Cura/gui/sliceProgessPanel.py +++ b/Cura/gui/sliceProgessPanel.py @@ -173,7 +173,7 @@ class WorkerThread(threading.Thread): wx.CallAfter(self.notifyWindow.statusText.SetLabel, line) if self.notifyWindow.abort: p.terminate() - wx.CallAfter(self.notifyWindow.statusText.SetLabel, "Aborted by user.") + wx.CallAfter(self.notifyWindow.mainWindow.removeSliceProgress, self.notifyWindow) return line = p.stdout.readline() line = p.stderr.readline() diff --git a/Cura/slice/__main__.py b/Cura/slice/__main__.py new file mode 100644 index 00000000..fef7c8f8 --- /dev/null +++ b/Cura/slice/__main__.py @@ -0,0 +1,112 @@ +from __future__ import absolute_import + +from optparse import OptionParser +import sys +import re + +from Cura.util import profile +from Cura.slice.cura_sf.skeinforge_application.skeinforge_plugins.craft_plugins import export + +def fixUTF8(input): + if input.startswith('#UTF8#'): + return input[6:].decode('utf-8') + return input + +def main(): + parser = OptionParser(usage="usage: %prog [options] [, ][, ...]") + parser.add_option("-p", "--profile", action="store", type="string", dest="profile", + help="Encoded profile to use for the print") + parser.add_option("-o", "--output", action="store", type="string", dest="output", + help="Output filename") + (options, args) = parser.parse_args() + if options.output is None: + print 'Missing output filename' + sys.exit(1) + if options.profile is not None: + profile.loadGlobalProfileFromString(options.profile) + options.output = fixUTF8(options.output) + + print args + resultFile = open(options.output, "w") + for idx in xrange(0, len(args), 2): + position = map(float, args[0].split(',')) + if len(position) < 9 + 2: + position = position[0:2] + position += [1,0,0] + position += [0,1,0] + position += [0,0,1] + filenames = fixUTF8(args[idx + 1]).split('|') + + if idx == 0: + resultFile.write(';TYPE:CUSTOM\n') + resultFile.write(profile.getAlterationFileContents('start.gcode').replace('?filename?', ' '.join(filenames).encode('ascii', 'replace'))) + else: + resultFile.write(';TYPE:CUSTOM\n') + resultFile.write(profile.getAlterationFileContents('nextobject.gcode').replace('?filename?', ' '.join(filenames).encode('ascii', 'replace'))) + + output = [] + for filename in filenames: + extruderNr = filenames.index(filename) + profile.resetTempOverride() + if extruderNr > 0: + profile.setTempOverride('object_center_x', position[0] - profile.getPreferenceFloat('extruder_offset_x%d' % (extruderNr))) + profile.setTempOverride('object_center_y', position[1] - profile.getPreferenceFloat('extruder_offset_y%d' % (extruderNr))) + profile.setTempOverride('fan_enabled', 'False') + profile.setTempOverride('skirt_line_count', '0') + profile.setTempOverride('alternative_center', filenames[0]) + else: + profile.setTempOverride('object_center_x', position[0]) + profile.setTempOverride('object_center_y', position[1]) + profile.setTempOverride('object_matrix', ','.join(map(str, position[2:11]))) + output.append(export.getOutput(filename)) + if len(output) == 1: + resultFile.write(output[0]) + else: + stitchMultiExtruder(output, resultFile) + resultFile.write(';TYPE:CUSTOM\n') + resultFile.write(profile.getAlterationFileContents('end.gcode')) + resultFile.close() + + print "Running plugins" + ret = profile.runPostProcessingPlugins(options.output) + if ret is not None: + print ret + + +def stitchMultiExtruder(outputList, resultFile): + print "Stitching %i files for multi-extrusion" % (len(outputList)) + currentExtruder = 0 + resultFile.write('T%d\n' % (currentExtruder)) + layerNr = -1 + hasLine = True + outputList = map(lambda o: o.split('\n'), outputList) + outputOrder = range(0, len(outputList)) + while hasLine: + hasLine = False + outputOrder.reverse() + for outputIdx in outputOrder: + layerHasLine = False + while len(outputList[outputIdx]) > 0: + line = outputList[outputIdx].pop(0) + hasLine = True + if line.startswith(';LAYER:'): + break + if 'Z' in line: + lastZ = float(re.search('Z([^\s]+)', line).group(1)) + if not layerHasLine: + nextExtruder = outputIdx + resultFile.write(';LAYER:%d\n' % (layerNr)) + resultFile.write(';EXTRUDER:%d\n' % (nextExtruder)) + if nextExtruder != currentExtruder: + resultFile.write(';TYPE:CUSTOM\n') + profile.setTempOverride('extruder', nextExtruder) + resultFile.write(profile.getAlterationFileContents('switchExtruder.gcode') + '\n') + profile.resetTempOverride() + currentExtruder = nextExtruder + layerHasLine = True + resultFile.write(line) + resultFile.write('\n') + layerNr += 1 + +if __name__ == '__main__': + main() diff --git a/Cura/util/profile.py b/Cura/util/profile.py index d86779f5..113c6cf1 100644 --- a/Cura/util/profile.py +++ b/Cura/util/profile.py @@ -176,11 +176,11 @@ preferencesDefaultSettings = { 'sdpath': '', 'sdshortnames': 'True', - 'extruder_head_size_min_x': '70.0', + 'extruder_head_size_min_x': '75.0', 'extruder_head_size_min_y': '18.0', 'extruder_head_size_max_x': '18.0', 'extruder_head_size_max_y': '35.0', - 'extruder_head_size_height': '80.0', + 'extruder_head_size_height': '60.0', 'model_colour': '#72CB30', 'model_colour2': '#CB3030', @@ -428,9 +428,9 @@ def getMachineCenterCoords(): def getObjectMatrix(): rotate = getProfileSettingFloat('model_rotate_base') rotate = rotate / 180.0 * math.pi - scaleX = 1.0 - scaleY = 1.0 - scaleZ = 1.0 + scaleX = getProfileSettingFloat('model_scale') + scaleY = getProfileSettingFloat('model_scale') + scaleZ = getProfileSettingFloat('model_scale') if getProfileSetting('flipX') == 'True': scaleX = -scaleX if getProfileSetting('flipY') == 'True':