示例#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)
示例#2
0
	def __init__(self, mainWindow, parent, filelist):
		wx.Panel.__init__(self, parent, -1)
		self.mainWindow = mainWindow
		self.filelist = filelist
		self.abort = False
		
		box = wx.StaticBox(self, -1, filelist[0])
		self.sizer = wx.StaticBoxSizer(box, wx.HORIZONTAL)

		mainSizer = wx.BoxSizer(wx.VERTICAL) 
		mainSizer.Add(self.sizer, 0, flag=wx.EXPAND)

		self.statusText = wx.StaticText(self, -1, "Starting...")
		self.progressGauge = wx.Gauge(self, -1)
		self.progressGauge.SetRange(10000 * len(filelist))
		self.abortButton = wx.Button(self, -1, "X", style=wx.BU_EXACTFIT)
		self.sizer.Add(self.statusText, 2, flag=wx.ALIGN_CENTER )
		self.sizer.Add(self.progressGauge, 2)
		self.sizer.Add(self.abortButton, 0)

		self.Bind(wx.EVT_BUTTON, self.OnAbort, self.abortButton)

		self.SetSizer(mainSizer)
		self.prevStep = 'start'
		self.totalDoneFactor = 0.0
		self.startTime = time.time()
		if profile.getPreference('save_profile') == 'True':
			profile.saveGlobalProfile(self.filelist[0][: self.filelist[0].rfind('.')] + "_profile.ini")
		center = profile.getMachineCenterCoords() + profile.getObjectMatrix()
		cmdList = [sliceRun.getSliceCommand(sliceRun.getExportFilename(self.filelist[0]), ['|'.join(self.filelist)], [center])]
		self.thread = WorkerThread(self, filelist, cmdList)
示例#3
0
文件: batchRun.py 项目: FMMT666/Cura
	def OnSlice(self, e):
		sliceCmdList = []
		for filename in self.list:
			sliceCmdList.append(sliceRun.getSliceCommand(filename))
		bspw = BatchSliceProgressWindow(self.list[:], sliceCmdList)
		bspw.Centre()
		bspw.Show(True)
示例#4
0
文件: batchRun.py 项目: EFinley/Cura
	def OnSlice(self, e):
		sliceCmdList = []
		center = profile.getMachineCenterCoords()
		for filename in self.list:
			sliceCmdList.append(sliceRun.getSliceCommand(sliceRun.getExportFilename(filename), [filename], [center]))
		bspw = BatchSliceProgressWindow(self.list[:], sliceCmdList)
		bspw.Centre()
		bspw.Show(True)
示例#5
0
    def __init__(self, mainWindow, parent, filelist):
        wx.Panel.__init__(self, parent, -1)
        self.mainWindow = mainWindow
        self.filelist = filelist
        self.abort = False

        box = wx.StaticBox(self, -1, filelist[0])
        self.sizer = wx.StaticBoxSizer(box, wx.HORIZONTAL)

        mainSizer = wx.BoxSizer(wx.VERTICAL)
        mainSizer.Add(self.sizer, 0, flag=wx.EXPAND)

        self.statusText = wx.StaticText(self, -1, "Starting...")
        self.progressGauge = wx.Gauge(self, -1)
        self.progressGauge.SetRange(10000 * len(filelist))
        self.abortButton = wx.Button(self, -1, "X", style=wx.BU_EXACTFIT)
        self.sizer.Add(self.statusText, 2, flag=wx.ALIGN_CENTER)
        self.sizer.Add(self.progressGauge, 2)
        self.sizer.Add(self.abortButton, 0)

        self.Bind(wx.EVT_BUTTON, self.OnAbort, self.abortButton)

        self.SetSizer(mainSizer)
        self.prevStep = 'start'
        self.totalDoneFactor = 0.0
        self.startTime = time.time()
        if profile.getPreference('save_profile') == 'True':
            profile.saveGlobalProfile(
                self.filelist[0][:self.filelist[0].rfind('.')] +
                "_profile.ini")
        center = profile.getMachineCenterCoords() + profile.getObjectMatrix()
        outputFilename = sliceRun.getExportFilename(self.filelist[0])

        if profile.getPreference('filename_prompt') == 'True' or (
                os.path.exists(outputFilename)
                and profile.getPreference('file_overwrite_prompt') == 'True'):
            style = wx.FD_SAVE
            if profile.getPreference('file_overwrite_prompt') == 'True':
                style = style | wx.FD_OVERWRITE_PROMPT
            dlg = wx.FileDialog(self,
                                "Select gcode file to save",
                                os.path.split(outputFilename)[0],
                                os.path.split(outputFilename)[1],
                                style=style)
            dlg.SetWildcard("gcode files (*.gcode, *.g)|*.gcode;*.g")
            if dlg.ShowModal() != wx.ID_OK:
                dlg.Destroy()
                self.abort = True
                self.statusText.SetLabel("Aborted by user.")
                return
            outputFilename = dlg.GetPath()
            dlg.Destroy()

        cmdList = [
            sliceRun.getSliceCommand(outputFilename, ['|'.join(self.filelist)],
                                     [center])
        ]
        self.thread = WorkerThread(self, filelist, cmdList)
示例#6
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)
示例#7
0
    def __init__(self, mainWindow, parent, filelist):
        wx.Panel.__init__(self, parent, -1)
        self.mainWindow = mainWindow
        self.filelist = filelist
        self.abort = False

        box = wx.StaticBox(self, -1, filelist[0])
        self.sizer = wx.StaticBoxSizer(box, wx.HORIZONTAL)

        mainSizer = wx.BoxSizer(wx.VERTICAL)
        mainSizer.Add(self.sizer, 0, flag=wx.EXPAND)

        self.statusText = wx.StaticText(self, -1, "Starting...")
        self.progressGauge = wx.Gauge(self, -1)
        self.progressGauge.SetRange(10000 * len(filelist))
        self.abortButton = wx.Button(self, -1, "X", style=wx.BU_EXACTFIT)
        self.sizer.Add(self.statusText, 2, flag=wx.ALIGN_CENTER)
        self.sizer.Add(self.progressGauge, 2)
        self.sizer.Add(self.abortButton, 0)

        self.Bind(wx.EVT_BUTTON, self.OnAbort, self.abortButton)

        self.SetSizer(mainSizer)
        self.prevStep = "start"
        self.totalDoneFactor = 0.0
        self.startTime = time.time()
        if profile.getPreference("save_profile") == "True":
            profile.saveGlobalProfile(self.filelist[0][: self.filelist[0].rfind(".")] + "_profile.ini")
        center = profile.getMachineCenterCoords() + profile.getObjectMatrix()
        outputFilename = sliceRun.getExportFilename(self.filelist[0])

        if profile.getPreference("filename_prompt") == "True" or (
            os.path.exists(outputFilename) and profile.getPreference("file_overwrite_prompt") == "True"
        ):
            style = wx.FD_SAVE
            if profile.getPreference("file_overwrite_prompt") == "True":
                style = style | wx.FD_OVERWRITE_PROMPT
            dlg = wx.FileDialog(
                self,
                "Select gcode file to save",
                os.path.split(outputFilename)[0],
                os.path.split(outputFilename)[1],
                style=style,
            )
            dlg.SetWildcard("gcode files (*.gcode, *.g)|*.gcode;*.g")
            if dlg.ShowModal() != wx.ID_OK:
                dlg.Destroy()
                self.abort = True
                self.statusText.SetLabel("Aborted by user.")
                return
            outputFilename = dlg.GetPath()
            dlg.Destroy()

        cmdList = [sliceRun.getSliceCommand(outputFilename, ["|".join(self.filelist)], [center])]
        self.thread = WorkerThread(self, filelist, cmdList)
示例#8
0
	def OnSlice(self, e):
		sliceCmdList = []
		outputFilenameList = []
		center = profile.getMachineCenterCoords() + profile.getObjectMatrix()
		for filename in self.list:
			outputFilename = sliceRun.getExportFilename(filename)
			outputFilenameList.append(outputFilename)
			sliceCmdList.append(sliceRun.getSliceCommand(outputFilename, [filename], [center]))
		bspw = BatchSliceProgressWindow(self.list[:], outputFilenameList, sliceCmdList)
		bspw.Centre()
		bspw.Show(True)
示例#9
0
	def __init__(self, mainWindow, parent, filelist):
		wx.Panel.__init__(self, parent, -1)
		self.mainWindow = mainWindow
		self.filelist = filelist
		self.abort = False
		
		box = wx.StaticBox(self, -1, filelist[0])
		self.sizer = wx.StaticBoxSizer(box, wx.HORIZONTAL)

		mainSizer = wx.BoxSizer(wx.VERTICAL) 
		mainSizer.Add(self.sizer, 0, flag=wx.EXPAND)

		self.statusText = wx.StaticText(self, -1, "Starting...")
		self.progressGauge = wx.Gauge(self, -1)
		self.progressGauge.SetRange(10000 * len(filelist))
		self.abortButton = wx.Button(self, -1, "X", style=wx.BU_EXACTFIT)
		self.sizer.Add(self.statusText, 2, flag=wx.ALIGN_CENTER )
		self.sizer.Add(self.progressGauge, 2)
		self.sizer.Add(self.abortButton, 0)

		self.Bind(wx.EVT_BUTTON, self.OnAbort, self.abortButton)

		self.SetSizer(mainSizer)
		self.prevStep = 'start'
		self.totalDoneFactor = 0.0
		self.startTime = time.time()
		if profile.getPreference('save_profile') == 'True':
			profile.saveGlobalProfile(self.filelist[0][: self.filelist[0].rfind('.')] + "_profile.ini")
		cmdList = []
		for filename in self.filelist:
			idx = self.filelist.index(filename)
			#print filename, idx
			if idx > 0:
				profile.setTempOverride('fan_enabled', 'False')
				profile.setTempOverride('skirt_line_count', '0')
				profile.setTempOverride('object_center_x', profile.getPreferenceFloat('machine_width') / 2 - profile.getPreferenceFloat('extruder_offset_x%d' % (idx)))
				profile.setTempOverride('object_center_y', profile.getPreferenceFloat('machine_depth') / 2 - profile.getPreferenceFloat('extruder_offset_y%d' % (idx)))
				profile.setTempOverride('alternative_center', self.filelist[0])
			if len(self.filelist) > 1:
				profile.setTempOverride('add_start_end_gcode', 'False')
				profile.setTempOverride('gcode_extension', 'multi_extrude_tmp')
			cmdList.append(sliceRun.getSliceCommand(filename))
		profile.resetTempOverride()
		self.thread = WorkerThread(self, filelist, cmdList)
示例#10
0
    def __init__(self, mainWindow, parent, filelist):
        wx.Panel.__init__(self, parent, -1)
        self.mainWindow = mainWindow
        self.filelist = filelist
        self.abort = False

        box = wx.StaticBox(self, -1, filelist[0])
        self.sizer = wx.StaticBoxSizer(box, wx.HORIZONTAL)

        mainSizer = wx.BoxSizer(wx.VERTICAL)
        mainSizer.Add(self.sizer, 0, flag=wx.EXPAND)

        self.statusText = wx.StaticText(self, -1, "Starting...")
        self.progressGauge = wx.Gauge(self, -1)
        self.progressGauge.SetRange(10000 * len(filelist))
        self.abortButton = wx.Button(self, -1, "X", style=wx.BU_EXACTFIT)
        self.sizer.Add(self.statusText, 2, flag=wx.ALIGN_CENTER)
        self.sizer.Add(self.progressGauge, 2)
        self.sizer.Add(self.abortButton, 0)

        self.Bind(wx.EVT_BUTTON, self.OnAbort, self.abortButton)

        self.SetSizer(mainSizer)
        self.prevStep = 'start'
        self.totalDoneFactor = 0.0
        self.startTime = time.time()
        if profile.getPreference('save_profile') == 'True':
            profile.saveGlobalProfile(
                self.filelist[0][:self.filelist[0].rfind('.')] +
                "_profile.ini")
        center = profile.getMachineCenterCoords() + profile.getObjectMatrix()
        cmdList = [
            sliceRun.getSliceCommand(
                sliceRun.getExportFilename(self.filelist[0]),
                ['|'.join(self.filelist)], [center])
        ]
        self.thread = WorkerThread(self, filelist, cmdList)
	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)
	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