Example #1
0
	def OnSlice(self, e):
		dlg=wx.FileDialog(self, "Save project gcode file", os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_SAVE)
		dlg.SetWildcard("GCode file (*.gcode)|*.gcode")
		if dlg.ShowModal() != wx.ID_OK:
			dlg.Destroy()
			return
		resultFilename = dlg.GetPath()
		dlg.Destroy()

		put = profile.setTempOverride
		oldProfile = profile.getGlobalProfileString()
		
		if self.printMode == 0:
			fileList = []
			positionList = []
			for item in self.list:
				fileList.append(item.filename)
				if profile.getPreference('machine_center_is_zero') == 'True':
					pos = [item.centerX - self.machineSize[0] / 2, item.centerY - self.machineSize[1] / 2]
				else:
					pos = [item.centerX, item.centerY]
				positionList.append(pos + (item.mesh.matrix * item.scale).reshape((9,)).tolist())
			sliceCommand = sliceRun.getSliceCommand(resultFilename, fileList, positionList)
		else:
			self._saveCombinedSTL(resultFilename + "_temp_.stl")
			sliceCommand = sliceRun.getSliceCommand(resultFilename, [resultFilename + "_temp_.stl"], [profile.getMachineCenterCoords()])

		pspw = ProjectSliceProgressWindow(sliceCommand, resultFilename, len(self.list))
		pspw.Centre()
		pspw.Show(True)
Example #2
0
def getSliceCommand(outputfilename, filenames, positions):
	pypyExe = getPyPyExe()
	if pypyExe is None:
		pypyExe = sys.executable
	cmd = [pypyExe, '-m', 'Cura.slice', '-p', profile.getGlobalProfileString(), '-o']
	try:
		cmd.append(str(outputfilename))
	except UnicodeEncodeError:
		cmd.append("#UTF8#" + outputfilename.encode("utf-8"))
	for idx in xrange(0, len(filenames)):
		filename = filenames[idx]
		position = positions[idx]
		cmd.append(','.join(map(str, position)))
		try:
			cmd.append(str(filename))
		except UnicodeEncodeError:
			cmd.append("#UTF8#" + filename.encode("utf-8"))
	return cmd
Example #3
0
    def OnSlice(self, e):
        dlg = wx.FileDialog(self,
                            "Save project gcode file",
                            os.path.split(
                                profile.getPreference('lastFile'))[0],
                            style=wx.FD_SAVE)
        dlg.SetWildcard("GCode file (*.gcode)|*.gcode")
        if dlg.ShowModal() != wx.ID_OK:
            dlg.Destroy()
            return
        resultFilename = dlg.GetPath()
        dlg.Destroy()

        put = profile.setTempOverride
        oldProfile = profile.getGlobalProfileString()

        if self.printMode == 0:
            fileList = []
            positionList = []
            for item in self.list:
                fileList.append(item.filename)
                if profile.getPreference('machine_center_is_zero') == 'True':
                    pos = [
                        item.centerX - self.machineSize[0] / 2,
                        item.centerY - self.machineSize[1] / 2
                    ]
                else:
                    pos = [item.centerX, item.centerY]
                positionList.append(pos +
                                    item.matrix.getA().flatten().tolist())
            print positionList
            sliceCommand = sliceRun.getSliceCommand(resultFilename, fileList,
                                                    positionList)
        else:
            self._saveCombinedSTL(resultFilename + "_temp_.stl")
            sliceCommand = sliceRun.getSliceCommand(
                resultFilename, [resultFilename + "_temp_.stl"],
                [profile.getMachineCenterCoords()])

        pspw = ProjectSliceProgressWindow(sliceCommand, resultFilename,
                                          len(self.list))
        pspw.Centre()
        pspw.Show(True)
Example #4
0
	def OnSlice(self, e):
		if len(self.filelist) < 1:
			wx.MessageBox('You need to load a file before you can prepare it.', 'Print error', wx.OK | wx.ICON_INFORMATION)
			return
		isSimple = profile.getPreference('startMode') == 'Simple'
		if isSimple:
			#save the current profile so we can put it back latter
			oldProfile = profile.getGlobalProfileString()
			self.simpleSettingsPanel.setupSlice()
		#Create a progress panel and add it to the window. The progress panel will start the Skein operation.
		spp = sliceProgessPanel.sliceProgessPanel(self, self, self.filelist)
		self.sizer.Add(spp, (len(self.progressPanelList)+2,0), span=(1, 3 + self.extruderCount), flag=wx.EXPAND)
		self.sizer.Layout()
		newSize = self.GetSize()
		newSize.IncBy(0, spp.GetSize().GetHeight())
		if newSize.GetWidth() < wx.GetDisplaySize()[0]:
			self.SetSize(newSize)
		self.progressPanelList.append(spp)
		if isSimple:
			profile.loadGlobalProfileFromString(oldProfile)
	def submitSliceInfoOnline(self):
		if profile.getPreference('submit_slice_information') != 'True':
			return
		if version.isDevVersion():
			return
		data = {
			'processor': platform.processor(),
			'machine': platform.machine(),
			'platform': platform.platform(),
			'profile': profile.getGlobalProfileString(),
			'preferences': profile.getGlobalPreferencesString(),
			'modelhash': self._modelHash,
			'version': version.getVersion(),
		}
		try:
			f = urllib2.urlopen("http://www.youmagine.com/curastats/", data = urllib.urlencode(data), timeout = 1)
			f.read()
			f.close()
		except:
			pass
Example #6
0
	def submitSliceInfoOnline(self):
		if profile.getPreference('submit_slice_information') != 'True':
			return
		if version.isDevVersion():
			return
		data = {
			'processor': platform.processor(),
			'machine': platform.machine(),
			'platform': platform.platform(),
			'profile': profile.getGlobalProfileString(),
			'preferences': profile.getGlobalPreferencesString(),
			'modelhash': self._modelHash,
			'version': version.getVersion(),
		}
		try:
			f = urllib2.urlopen("http://www.youmagine.com/curastats/", data = urllib.urlencode(data), timeout = 1)
			f.read()
			f.close()
		except:
			pass
Example #7
0
 def OnSlice(self, e):
     if len(self.filelist) < 1:
         wx.MessageBox('You need to load a file before you can prepare it.',
                       'Print error', wx.OK | wx.ICON_INFORMATION)
         return
     isSimple = profile.getPreference('startMode') == 'Simple'
     if isSimple:
         #save the current profile so we can put it back latter
         oldProfile = profile.getGlobalProfileString()
         self.simpleSettingsPanel.setupSlice()
     #Create a progress panel and add it to the window. The progress panel will start the Skein operation.
     spp = sliceProgressPanel.sliceProgressPanel(self, self, self.filelist)
     self.sizer.Add(spp, 0, flag=wx.EXPAND)
     self.sizer.Layout()
     newSize = self.GetSize()
     newSize.IncBy(0, spp.GetSize().GetHeight())
     if newSize.GetWidth() < wx.GetDisplaySize()[0]:
         self.SetSize(newSize)
     self.progressPanelList.append(spp)
     if isSimple:
         profile.loadGlobalProfileFromString(oldProfile)
Example #8
0
def getSliceCommand(outputfilename, filenames, positions):
    pypyExe = getPyPyExe()
    if pypyExe is None:
        pypyExe = sys.executable
    cmd = [
        pypyExe, '-m', 'Cura.slice', '-p',
        profile.getGlobalProfileString(), '-o'
    ]
    try:
        cmd.append(str(outputfilename))
    except UnicodeEncodeError:
        cmd.append("#UTF8#" + outputfilename.encode("utf-8"))
    for idx in xrange(0, len(filenames)):
        filename = filenames[idx]
        position = positions[idx]
        cmd.append(','.join(map(str, position)))
        try:
            cmd.append(str(filename))
        except UnicodeEncodeError:
            cmd.append("#UTF8#" + filename.encode("utf-8"))
    return cmd
	def OnSlice(self, e):
		dlg=wx.FileDialog(self, "Save project gcode file", os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_SAVE)
		dlg.SetWildcard("GCode file (*.gcode)|*.gcode")
		if dlg.ShowModal() != wx.ID_OK:
			dlg.Destroy()
			return
		resultFilename = dlg.GetPath()
		dlg.Destroy()

		put = profile.setTempOverride
		oldProfile = profile.getGlobalProfileString()
		
		put('add_start_end_gcode', 'False')
		put('gcode_extension', 'project_tmp')
		if self.printMode == 0:
			clearZ = 0
			actionList = []
			for item in self.list:
				if item.profile != None and os.path.isfile(item.profile):
					profile.loadGlobalProfile(item.profile)
				put('object_center_x', item.centerX - self.extruderOffset[item.extruder][0])
				put('object_center_y', item.centerY - self.extruderOffset[item.extruder][1])
				put('model_scale', item.scale)
				put('flip_x', item.flipX)
				put('flip_y', item.flipY)
				put('flip_z', item.flipZ)
				put('model_rotate_base', item.rotate)
				put('swap_xz', item.swapXZ)
				put('swap_yz', item.swapYZ)
				
				action = Action()
				action.sliceCmd = sliceRun.getSliceCommand(item.filename)
				print action.sliceCmd
				action.centerX = item.centerX
				action.centerY = item.centerY
				action.temperature = profile.getProfileSettingFloat('print_temperature')
				action.extruder = item.extruder
				action.filename = item.filename
				clearZ = max(clearZ, item.getSize()[2] * item.scale + 5.0)
				action.clearZ = clearZ
				action.leaveResultForNextSlice = False
				action.usePreviousSlice = False
				actionList.append(action)

				if self.list.index(item) > 0 and item.isSameExceptForPosition(self.list[self.list.index(item)-1]):
					actionList[-2].leaveResultForNextSlice = True
					actionList[-1].usePreviousSlice = True

				if item.profile != None:
					profile.loadGlobalProfileFromString(oldProfile)
			
		else:
			self._saveCombinedSTL(resultFilename + "_temp_.stl")
			put('model_scale', 1.0)
			put('flip_x', False)
			put('flip_y', False)
			put('flip_z', False)
			put('model_rotate_base', 0)
			put('swap_xz', False)
			put('swap_yz', False)
			actionList = []
			
			action = Action()
			action.sliceCmd = sliceRun.getSliceCommand(resultFilename + "_temp_.stl")
			action.centerX = profile.getPreferenceFloat('machine_width') / 2
			action.centerY = profile.getPreferenceFloat('machine_depth') / 2
			action.temperature = profile.getProfileSettingFloat('print_temperature')
			action.extruder = 0
			action.filename = resultFilename + "_temp_.stl"
			action.clearZ = 0
			action.leaveResultForNextSlice = False
			action.usePreviousSlice = False

			actionList.append(action)
		
		#Restore the old profile.
		profile.resetTempOverride()
		
		pspw = ProjectSliceProgressWindow(actionList, resultFilename)
		pspw.extruderOffset = self.extruderOffset
		pspw.Centre()
		pspw.Show(True)
Example #10
0
def getSliceCommand(filename):
	if profile.getPreference('slicer').startswith('Slic3r') and getSlic3rExe() != False:
		slic3rExe = getSlic3rExe()
		if slic3rExe == False:
			return False
		cmd = [slic3rExe,
			'--output-filename-format', '[input_filename_base].gcode',
			'--nozzle-diameter', str(profile.calculateEdgeWidth()),
			'--print-center', '%s,%s' % (profile.getPreferenceFloat('machine_width') / 2, profile.getPreferenceFloat('machine_depth') / 2),
			'--z-offset', '0',
			'--gcode-flavor', 'reprap',
			'--gcode-comments',
			'--filament-diameter', profile.getProfileSetting('filament_diameter'),
			'--extrusion-multiplier', str(1.0 / float(profile.getProfileSetting('filament_density'))),
			'--temperature', profile.getProfileSetting('print_temperature'),
			'--travel-speed', profile.getProfileSetting('travel_speed'),
			'--perimeter-speed', profile.getProfileSetting('print_speed'),
			'--small-perimeter-speed', profile.getProfileSetting('print_speed'),
			'--infill-speed', profile.getProfileSetting('print_speed'),
			'--solid-infill-speed', profile.getProfileSetting('print_speed'),
			'--bridge-speed', profile.getProfileSetting('print_speed'),
			'--bottom-layer-speed-ratio', str(float(profile.getProfileSetting('bottom_layer_speed')) / float(profile.getProfileSetting('print_speed'))),
			'--layer-height', profile.getProfileSetting('layer_height'),
			'--first-layer-height-ratio', '1.0',
			'--infill-every-layers', '1',
			'--perimeters', str(profile.calculateLineCount()),
			'--solid-layers', str(profile.calculateSolidLayerCount()),
			'--fill-density', str(float(profile.getProfileSetting('fill_density'))/100),
			'--fill-angle', '45',
			'--fill-pattern', 'rectilinear', #rectilinear line concentric hilbertcurve archimedeanchords octagramspiral
			'--solid-fill-pattern', 'rectilinear',
			'--start-gcode', profile.getAlterationFilePath('start.gcode'),
			'--end-gcode', profile.getAlterationFilePath('end.gcode'),
			'--retract-length', profile.getProfileSetting('retraction_amount'),
			'--retract-speed', str(int(float(profile.getProfileSetting('retraction_speed')))),
			'--retract-restart-extra', profile.getProfileSetting('retraction_extra'),
			'--retract-before-travel', profile.getProfileSetting('retraction_min_travel'),
			'--retract-lift', '0',
			'--slowdown-below-layer-time', profile.getProfileSetting('cool_min_layer_time'),
			'--min-print-speed', profile.getProfileSetting('cool_min_feedrate'),
			'--skirts', profile.getProfileSetting('skirt_line_count'),
			'--skirt-distance', str(int(float(profile.getProfileSetting('skirt_gap')))),
			'--skirt-height', '1',
			'--scale', profile.getProfileSetting('model_scale'),
			'--rotate', profile.getProfileSetting('model_rotate_base'),
			'--duplicate-x', profile.getProfileSetting('model_multiply_x'),
			'--duplicate-y', profile.getProfileSetting('model_multiply_y'),
			'--duplicate-distance', '10']
		if profile.getProfileSetting('support') != 'None':
			cmd.extend(['--support-material'])
		cmd.extend([filename])
		return cmd
	else:
		pypyExe = getPyPyExe()
		if pypyExe == False:
			pypyExe = sys.executable
		
		#In case we have a frozen exe, then argv[0] points to the executable, but we want to give pypy a real script file.
		if hasattr(sys, 'frozen'):
			mainScriptFile = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../..", "cura_sf.zip"))
		else:
			mainScriptFile = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", os.path.split(sys.argv[0])[1]))
		cmd = [pypyExe, mainScriptFile, '-p', profile.getGlobalProfileString(), '-s']
		if platform.system() == "Windows":
			try:
				cmd.append(str(filename))
			except UnicodeEncodeError:
				cmd.append("#UTF8#" + filename.encode("utf-8"))
		else:
			cmd.append(filename)
		return cmd
Example #11
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 #12
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 #13
0
    def OnSlice(self, e):
        if len(self.filelist) < 1:
            wx.MessageBox(
                "You need to load a file before you can prepare it.", "Print error", wx.OK | wx.ICON_INFORMATION
            )
            return
            # save the current profile so we can put it back latter
        oldProfile = profile.getGlobalProfileString()

        put = profile.putProfileSetting
        get = profile.getProfileSetting

        put("layer_height", "0.2")
        put("wall_thickness", "0.8")
        put("solid_layer_thickness", "0.6")
        put("fill_density", "20")
        put("skirt_line_count", "1")
        put("skirt_gap", "6.0")
        put("print_speed", "50")
        put("print_temperature", "220")
        put("support", "None")
        put("retraction_enable", "False")
        put("retraction_min_travel", "5.0")
        put("retraction_speed", "40.0")
        put("retraction_amount", "4.5")
        put("retraction_extra", "0.0")
        put("travel_speed", "150")
        put("max_z_speed", "3.0")
        put("bottom_layer_speed", "25")
        put("cool_min_layer_time", "10")
        put("fan_enabled", "True")
        put("fan_layer", "1")
        put("fan_speed", "100")
        # put('model_scale', '1.0')
        # put('flip_x', 'False')
        # put('flip_y', 'False')
        # put('flip_z', 'False')
        # put('model_rotate_base', '0')
        # put('model_multiply_x', '1')
        # put('model_multiply_y', '1')
        put("extra_base_wall_thickness", "0.0")
        put("sequence", "Loops > Perimeter > Infill")
        put("force_first_layer_sequence", "True")
        put("infill_type", "Line")
        put("solid_top", "True")
        put("fill_overlap", "15")
        put("support_rate", "50")
        put("support_distance", "0.5")
        put("joris", "False")
        put("cool_min_feedrate", "5")
        put("bridge_speed", "100")
        put("raft_margin", "5")
        put("raft_base_material_amount", "100")
        put("raft_interface_material_amount", "100")
        put("bottom_thickness", "0.0")

        if self.printSupport.GetValue():
            put("support", "Exterior Only")

        nozzle_size = float(get("nozzle_size"))
        if self.printTypeNormal.GetValue():
            put("wall_thickness", nozzle_size * 2.0)
            put("layer_height", "0.2")
            put("fill_density", "20")
        elif self.printTypeLow.GetValue():
            put("wall_thickness", nozzle_size * 1.4)
            put("layer_height", "0.25")
            put("fill_density", "10")
            put("print_speed", "80")
            put("cool_min_layer_time", "3")
            put("bottom_layer_speed", "40")
        elif self.printTypeHigh.GetValue():
            put("wall_thickness", nozzle_size * 2.0)
            put("layer_height", "0.1")
            put("fill_density", "30")
            put("bottom_layer_speed", "15")
            put("bottom_thickness", "0.2")
        elif self.printTypeJoris.GetValue():
            put("wall_thickness", nozzle_size * 1.5)
            put("layer_height", "0.3")
            put("solid_layer_thickness", "0.9")
            put("fill_density", "0")
            put("joris", "True")
            put("extra_base_wall_thickness", "15.0")
            put("sequence", "Infill > Loops > Perimeter")
            put("force_first_layer_sequence", "False")
            put("solid_top", "False")
            put("support", "None")
            put("cool_min_layer_time", "3")

        put("filament_diameter", self.printMaterialDiameter.GetValue())
        if self.printMaterialPLA.GetValue():
            put("filament_density", "1.00")
            put("enable_raft", "False")
            put("skirt_line_count", "1")
        if self.printMaterialABS.GetValue():
            put("filament_density", "0.85")
            put("enable_raft", "True")
            put("skirt_line_count", "0")
            put("fan_layer", "1")
            put("bottom_thickness", "0.0")
            put("print_temperature", "260")

            # Create a progress panel and add it to the window. The progress panel will start the Skein operation.
        spp = sliceProgessPanel.sliceProgessPanel(self, self, self.filelist)
        self.sizer.Add(spp, (len(self.progressPanelList) + 2, 0), span=(1, 4), flag=wx.EXPAND)
        self.sizer.Layout()
        newSize = self.GetSize()
        newSize.IncBy(0, spp.GetSize().GetHeight())
        if newSize.GetWidth() < wx.GetDisplaySize()[0]:
            self.SetSize(newSize)
        self.progressPanelList.append(spp)

        # Restore the old profile.
        profile.loadGlobalProfileFromString(oldProfile)
	def runSlicer(self, list, name, sceneView):
		#dlg=wx.FileDialog(self, "Save project gcode file", os.path.split(profile2.getPreference('lastFile'))[0], style=wx.FD_SAVE)
		#dlg.SetWildcard("GCode file (*.gcode)|*.gcode")
		#if dlg.ShowModal() != wx.ID_OK:
		#	dlg.Destroy()
		#	return
		#print sceneView
		resultFilename = name
		#dlg.Destroy()

		put = profile.setTempOverride
		oldProfile = profile.getGlobalProfileString()
		
		put('add_start_end_gcode', 'False')
		put('gcode_extension', 'project_tmp')
		#if self.printMode == 0:
		if 0:
			clearZ = 0
			actionList = []
			for item in list:
				if item.profile != None and os.path.isfile(item.profile):
					profile.loadGlobalProfile(item.profile)
				put('object_center_x', item.centerX - self.extruderOffset[item.extruder][0])
				put('object_center_y', item.centerY - self.extruderOffset[item.extruder][1])
				put('model_scale', item.scale)
				put('flip_x', item.flipX)
				put('flip_y', item.flipY)
				put('flip_z', item.flipZ)
				put('model_rotate_base', item.rotate)
				put('swap_xz', item.swapXZ)
				put('swap_yz', item.swapYZ)
				
				action = Action()
				action.sliceCmd = sliceRun.getSliceCommand(item.filename)
				action.centerX = item.centerX
				action.centerY = item.centerY
				action.temperature = profile.getProfileSettingFloat('print_temperature')
				action.extruder = item.extruder
				action.filename = item.filename
				clearZ = max(clearZ, item.getSize()[2] * item.scale + 5.0)
				action.clearZ = clearZ
				action.leaveResultForNextSlice = False
				action.usePreviousSlice = False
				actionList.append(action)

				if list.index(item) > 0 and item.isSameExceptForPosition(list[list.index(item)-1]):
					actionList[-2].leaveResultForNextSlice = True
					actionList[-1].usePreviousSlice = True

				if item.profile != None:
					profile.loadGlobalProfileFromString(oldProfile)
			
		else:
			#self._saveCombinedSTL(resultFilename + "_temp_.stl", list)
			meshLoader.saveMeshes(resultFilename + "_temp_.stl", list)

			put('model_scale', 1.0)
			put('flip_x', False)
			put('flip_y', False)
			put('flip_z', False)
			put('model_rotate_base', 0)
			put('swap_xz', False)
			put('swap_yz', False)
			put('object_center_x', sceneView._scene.getMinMaxPosition()[0] + (profile.getPreferenceFloat('machine_width') / 2))
			put('object_center_y', sceneView._scene.getMinMaxPosition()[1] + (profile.getPreferenceFloat('machine_depth') / 2))  
			actionList = []
			#print sceneView._scene.getMinMaxPosition()
			action = Action()
			action.sliceCmd = sliceRun.getSliceCommand(resultFilename + "_temp_.stl")
			action.centerX = profile.getPreferenceFloat('machine_width') / 2 #these dont do squat! but they have to be here. 
			action.centerY = profile.getPreferenceFloat('machine_depth') / 2
			#action.centerX = 0
			#action.centerY = 300
			action.temperature = profile.getProfileSettingFloat('print_temperature')
			action.extruder = 0
			action.filename = resultFilename + "_temp_.stl"
			action.clearZ = 0
			action.leaveResultForNextSlice = False
			action.usePreviousSlice = False

			actionList.append(action)
		
		#Restore the old profile.
		profile.resetTempOverride()
		
		self._pspw = ProjectSliceProgressWindow(self, actionList, resultFilename, sceneView)
		self._pspw.extruderOffset = self.extruderOffset
		self._pspw.Centre()

		if version.isDevVersion():
			self._pspw.Show(True) #DEBUG
Example #15
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
Example #16
0
    def setupSlice(self):
        # save the current profile so we can put it back latter
        oldProfile = profile.getGlobalProfileString()

        put = profile.putProfileSetting
        get = profile.getProfileSetting

        put("layer_height", "0.2")
        put("wall_thickness", "0.8")
        put("solid_layer_thickness", "0.6")
        put("fill_density", "20")
        put("skirt_line_count", "1")
        put("skirt_gap", "6.0")
        put("print_speed", "50")
        put("print_temperature", "220")
        put("support", "None")
        put("retraction_enable", "False")
        put("retraction_min_travel", "5.0")
        put("retraction_speed", "40.0")
        put("retraction_amount", "4.5")
        put("retraction_extra", "0.0")
        put("travel_speed", "150")
        put("max_z_speed", "3.0")
        put("bottom_layer_speed", "25")
        put("cool_min_layer_time", "10")
        put("fan_enabled", "True")
        put("fan_layer", "1")
        put("fan_speed", "100")
        # put('model_scale', '1.0')
        # put('flip_x', 'False')
        # put('flip_y', 'False')
        # put('flip_z', 'False')
        # put('model_rotate_base', '0')
        # put('model_multiply_x', '1')
        # put('model_multiply_y', '1')
        put("extra_base_wall_thickness", "0.0")
        put("sequence", "Loops > Perimeter > Infill")
        put("force_first_layer_sequence", "True")
        put("infill_type", "Line")
        put("solid_top", "True")
        put("fill_overlap", "15")
        put("support_rate", "50")
        put("support_distance", "0.5")
        put("joris", "False")
        put("cool_min_feedrate", "5")
        put("bridge_speed", "100")
        put("raft_margin", "5")
        put("raft_base_material_amount", "100")
        put("raft_interface_material_amount", "100")
        put("bottom_thickness", "0.0")

        if self.printSupport.GetValue():
            put("support", "Exterior Only")

        nozzle_size = float(get("nozzle_size"))
        if self.printTypeNormal.GetValue():
            put("wall_thickness", nozzle_size * 2.0)
            put("layer_height", "0.2")
            put("fill_density", "20")
        elif self.printTypeLow.GetValue():
            put("wall_thickness", nozzle_size * 1.4)
            put("layer_height", "0.25")
            put("fill_density", "10")
            put("print_speed", "80")
            put("cool_min_layer_time", "3")
            put("bottom_layer_speed", "40")
        elif self.printTypeHigh.GetValue():
            put("wall_thickness", nozzle_size * 2.0)
            put("layer_height", "0.1")
            put("fill_density", "30")
            put("bottom_layer_speed", "15")
            put("bottom_thickness", "0.2")
        elif self.printTypeJoris.GetValue():
            put("wall_thickness", nozzle_size * 1.5)
            put("layer_height", "0.3")
            put("solid_layer_thickness", "0.9")
            put("fill_density", "0")
            put("joris", "True")
            put("extra_base_wall_thickness", "15.0")
            put("sequence", "Infill > Loops > Perimeter")
            put("force_first_layer_sequence", "False")
            put("solid_top", "False")
            put("support", "None")
            put("cool_min_layer_time", "3")

        put("filament_diameter", self.printMaterialDiameter.GetValue())
        if self.printMaterialPLA.GetValue():
            put("filament_density", "1.00")
            put("enable_raft", "False")
            put("skirt_line_count", "1")
        if self.printMaterialABS.GetValue():
            put("filament_density", "0.85")
            put("enable_raft", "True")
            put("skirt_line_count", "0")
            put("fan_layer", "1")
            put("bottom_thickness", "0.0")
            put("print_temperature", "260")
        put("plugin_config", "")