Example #1
0
def main():
	parser = OptionParser(usage="usage: %prog [options] <X,Y> <filename>[, <X,Y> <filename>][, ...]")
	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)

	clearZ = 0
	resultFile = open(options.output, "w")
	for idx in xrange(0, len(args), 2):
		position = map(float, args[idx].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('|')

		profile.setTempOverride('object_center_x', position[0])
		profile.setTempOverride('object_center_y', position[1])
		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')
			n = output[-1].rfind('Z')+1
			zString = output[-1][n:n+20]
			zString = zString[0:zString.find(' ')]
			clearZ = max(clearZ, float(zString) + 10)
			profile.setTempOverride('clear_z', clearZ)
			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))
			profile.resetTempOverride()
		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
	print "Finalizing %s" % (os.path.basename(options.output))
Example #2
0
def main():
	parser = OptionParser(usage="usage: %prog [options] <X,Y> <filename>[, <X,Y> <filename>][, ...]")
	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)

	clearZ = 0
	resultFile = open(options.output, "w")
	for idx in xrange(0, len(args), 2):
		position = map(float, args[idx].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('|')

		profile.setTempOverride('object_center_x', position[0])
		profile.setTempOverride('object_center_y', position[1])
		if idx == 0:
			resultFile.write(';TYPE:CUSTOM\n')
			resultFile.write(profile.getAlterationFileContents('start.gcode', len(filenames)).replace('?filename?', ' '.join(filenames).encode('ascii', 'replace')))
		else:
			resultFile.write(';TYPE:CUSTOM\n')
			n = output[-1].rfind('Z')+1
			zString = output[-1][n:n+20]
			zString = zString[0:zString.find(' ')]
			clearZ = max(clearZ, float(zString) + 10)
			profile.setTempOverride('clear_z', clearZ)
			print position
			print profile.getAlterationFileContents('nextobject.gcode')
			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])))
			if extruderNr > 0:
				if profile.getProfileSettingFloat('filament_diameter%d' % (extruderNr + 1)) > 0:
					profile.setTempOverride('filament_diameter', profile.getProfileSetting('filament_diameter%d' % (extruderNr + 1)))
			print extruderNr, profile.getPreferenceFloat('extruder_offset_x%d' % (extruderNr)), profile.getPreferenceFloat('extruder_offset_y%d' % (extruderNr))
			output.append(export.getOutput(filename))
			profile.resetTempOverride()
		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
	print "Finalizing %s" % (os.path.basename(options.output))
	if profile.getPreference('submit_slice_information') == 'True':
		filenames = fixUTF8(args[idx + 1]).split('|')
		for filename in filenames:
			m = hashlib.sha512()
			f = open(filename, "rb")
			while True:
				chunk = f.read(1024)
				if not chunk:
					break
				m.update(chunk)
			f.close()
			data = {
				'processor': platform.processor(),
				'machine': platform.machine(),
				'platform': platform.platform(),
				'profile': profile.getGlobalProfileString(),
				'preferences': profile.getGlobalPreferencesString(),
				'modelhash': m.hexdigest(),
				'version': version.getVersion(),
			}
			try:
				f = urllib2.urlopen("http://platform.ultimaker.com/curastats/", data = urllib.urlencode(data), timeout = 5);
				f.read()
				f.close()
			except:
				pass
Example #3
0
def main():
    parser = OptionParser(
        usage=
        "usage: %prog [options] <X,Y> <filename>[, <X,Y> <filename>][, ...]")
    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)

    clearZ = 0
    resultFile = open(options.output, "w")
    for idx in xrange(0, len(args), 2):
        position = map(float, args[idx].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('|')

        profile.setTempOverride('object_center_x', position[0])
        profile.setTempOverride('object_center_y', position[1])
        if idx == 0:
            resultFile.write(';TYPE:CUSTOM\n')
            resultFile.write(
                profile.getAlterationFileContents(
                    'start.gcode', len(filenames)).replace(
                        '?filename?',
                        ' '.join(filenames).encode('ascii', 'replace')))
        else:
            resultFile.write(';TYPE:CUSTOM\n')
            n = output[-1].rfind('Z') + 1
            zString = output[-1][n:n + 20]
            zString = zString[0:zString.find(' ')]
            clearZ = max(clearZ, float(zString) + 10)
            profile.setTempOverride('clear_z', clearZ)
            print position
            print profile.getAlterationFileContents('nextobject.gcode')
            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])))
            if extruderNr > 0:
                if profile.getProfileSettingFloat('filament_diameter%d' %
                                                  (extruderNr + 1)) > 0:
                    profile.setTempOverride(
                        'filament_diameter',
                        profile.getProfileSetting('filament_diameter%d' %
                                                  (extruderNr + 1)))
            print extruderNr, profile.getPreferenceFloat(
                'extruder_offset_x%d' %
                (extruderNr)), profile.getPreferenceFloat(
                    'extruder_offset_y%d' % (extruderNr))
            output.append(export.getOutput(filename))
            profile.resetTempOverride()
        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
    print "Finalizing %s" % (os.path.basename(options.output))
    if profile.getPreference('submit_slice_information') == 'True':
        filenames = fixUTF8(args[idx + 1]).split('|')
        for filename in filenames:
            m = hashlib.sha512()
            f = open(filename, "rb")
            while True:
                chunk = f.read(1024)
                if not chunk:
                    break
                m.update(chunk)
            f.close()
            data = {
                'processor': platform.processor(),
                'machine': platform.machine(),
                'platform': platform.platform(),
                'profile': profile.getGlobalProfileString(),
                'preferences': profile.getGlobalPreferencesString(),
                'modelhash': m.hexdigest(),
                'version': version.getVersion(),
            }
            try:
                f = urllib2.urlopen("http://platform.ultimaker.com/curastats/",
                                    data=urllib.urlencode(data),
                                    timeout=5)
                f.read()
                f.close()
            except:
                pass
Example #4
0
def main():
    parser = OptionParser(usage="usage: %prog [options] <X,Y> <filename>[, <X,Y> <filename>][, ...]")
    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)

    clearZ = 0
    resultFile = open(options.output, "w")
    for idx in xrange(0, len(args), 2):
        position = map(float, args[idx].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("|")

        profile.setTempOverride("object_center_x", position[0])
        profile.setTempOverride("object_center_y", position[1])
        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")
            n = output[-1].rfind("Z") + 1
            zString = output[-1][n : n + 20]
            zString = zString[0 : zString.find(" ")]
            clearZ = max(clearZ, float(zString) + 10)
            profile.setTempOverride("clear_z", clearZ)
            print position
            print profile.getAlterationFileContents("nextobject.gcode")
            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))
            profile.resetTempOverride()
        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
    print "Finalizing %s" % (os.path.basename(options.output))
    if profile.getPreference("submit_slice_information") == "True":
        filenames = fixUTF8(args[idx + 1]).split("|")
        for filename in filenames:
            m = hashlib.sha512()
            f = open(filename, "rb")
            while True:
                chunk = f.read(1024)
                if not chunk:
                    break
                m.update(chunk)
            f.close()
            data = {
                "processor": platform.processor(),
                "machine": platform.machine(),
                "platform": platform.platform(),
                "profile": profile.getGlobalProfileString(),
                "preferences": profile.getGlobalPreferencesString(),
                "modelhash": m.hexdigest(),
                "version": version.getVersion(),
            }
            try:
                f = urllib2.urlopen("http://platform.ultimaker.com/curastats/", data=urllib.urlencode(data), timeout=5)
                f.read()
                f.close()
            except:
                pass