示例#1
0
文件: mainWindow.py 项目: younew/Cura
 def OnLoadProfileFromGcode(self, e):
     dlg = wx.FileDialog(
         self,
         "Select gcode file to load profile from",
         os.path.split(profile.getPreference("lastFile"))[0],
         style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST,
     )
     dlg.SetWildcard("gcode files (*.gcode)|*.gcode")
     if dlg.ShowModal() == wx.ID_OK:
         gcodeFile = dlg.GetPath()
         f = open(gcodeFile, "r")
         hasProfile = False
         for line in f:
             if line.startswith(";CURA_PROFILE_STRING:"):
                 profile.loadGlobalProfileFromString(line[line.find(":") + 1 :].strip())
                 hasProfile = True
         if hasProfile:
             self.updateProfileToControls()
         else:
             wx.MessageBox(
                 "No profile found in GCode file.\nThis feature only works with GCode files made by Cura 12.07 or newer.",
                 "Profile load error",
                 wx.OK | wx.ICON_INFORMATION,
             )
     dlg.Destroy()
示例#2
0
文件: cura.py 项目: danilke/Cura
def main():
	parser = OptionParser(usage="usage: %prog [options] <filename>.stl")
	parser.add_option("-i", "--ini", action="store", type="string", dest="profileini", help="Load settings from a profile ini file")
	parser.add_option("-P", "--project", action="store_true", dest="openprojectplanner", help="Open the project planner")
	parser.add_option("-F", "--flat", action="store_true", dest="openflatslicer", help="Open the 2D SVG slicer")
	parser.add_option("-r", "--print", action="store", type="string", dest="printfile", help="Open the printing interface, instead of the normal cura interface.")
	parser.add_option("-p", "--profile", action="store", type="string", dest="profile", help="Internal option, do not use!")
	(options, args) = parser.parse_args()
	if options.profile != None:
		profile.loadGlobalProfileFromString(options.profile)
	if options.profileini != None:
		profile.loadGlobalProfile(options.profileini)
	if options.openprojectplanner != None:
		from gui import projectPlanner
		projectPlanner.main()
		return
	if options.openflatslicer != None:
		from gui import flatSlicerWindow
		flatSlicerWindow.main()
		return
	if options.printfile != None:
		from gui import printWindow
		printWindow.startPrintInterface(options.printfile)
		return

	if len( args ) > 0:
		sliceRun.runSlice(args)
	else:
		from gui import mainWindow
		mainWindow.main()
示例#3
0
def main():
	parser = OptionParser(usage="usage: %prog [options] <filename>.stl")
	parser.add_option("-i", "--ini", action="store", type="string", dest="profileini", help="Load settings from a profile ini file")
	parser.add_option("-P", "--project", action="store_true", dest="openprojectplanner", help="Open the project planner")
	parser.add_option("-F", "--flat", action="store_true", dest="openflatslicer", help="Open the 2D SVG slicer (unfinished)")
	parser.add_option("-r", "--print", action="store", type="string", dest="printfile", help="Open the printing interface, instead of the normal cura interface.")
	parser.add_option("-p", "--profile", action="store", type="string", dest="profile", help="Internal option, do not use!")
	parser.add_option("-s", "--slice", action="store_true", dest="slice", help="Slice the given files instead of opening them in Cura")
	(options, args) = parser.parse_args()
	if options.profile != None:
		profile.loadGlobalProfileFromString(options.profile)
	if options.profileini != None:
		profile.loadGlobalProfile(options.profileini)
	if options.openprojectplanner != None:
		from gui import projectPlanner
		projectPlanner.main()
		return
	if options.openflatslicer != None:
		from gui import flatSlicerWindow
		flatSlicerWindow.main()
		return
	if options.printfile != None:
		from gui import printWindow
		printWindow.startPrintInterface(options.printfile)
		return

	if options.slice != None:
		from util import sliceRun
		sliceRun.runSlice(args)
	else:
		if len(args) > 0:
			profile.putPreference('lastFile', ';'.join(args))
		from gui import splashScreen
		splashScreen.showSplash(mainWindowRunCallback)
示例#4
0
	def OnSlice(self, e):
		put = profile.setTempOverride
		oldProfile = profile.getGlobalProfileString()

		put('model_multiply_x', '1')
		put('model_multiply_y', '1')
		put('enable_raft', 'False')
		put('add_start_end_gcode', 'False')
		put('gcode_extension', 'project_tmp')
		
		clearZ = 0
		actionList = []
		for item in self.list:
			if item.profile != None and os.path.isfile(item.profile):
				profile.loadGlobalProfile(item.profile)
			put('machine_center_x', item.centerX - self.extruderOffset[item.extruder].x)
			put('machine_center_y', item.centerY - self.extruderOffset[item.extruder].y)
			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.extruder = item.extruder
			action.filename = item.filename
			clearZ = max(clearZ, item.getMaximum().z * 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)
		
		#Restore the old profile.
		profile.resetTempOverride()
		
		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()
		
		pspw = ProjectSliceProgressWindow(actionList, resultFilename)
		pspw.extruderOffset = self.extruderOffset
		pspw.Centre()
		pspw.Show(True)
示例#5
0
 def OnLoadProfileFromGcode(self, e):
     dlg = wx.FileDialog(self,
                         "Select gcode file to load profile from",
                         os.path.split(
                             profile.getPreference('lastFile'))[0],
                         style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
     dlg.SetWildcard("gcode files (*.gcode)|*.gcode;*.g")
     if dlg.ShowModal() == wx.ID_OK:
         gcodeFile = dlg.GetPath()
         f = open(gcodeFile, 'r')
         hasProfile = False
         for line in f:
             if line.startswith(';CURA_PROFILE_STRING:'):
                 profile.loadGlobalProfileFromString(line[line.find(':') +
                                                          1:].strip())
                 hasProfile = True
         if hasProfile:
             self.updateProfileToControls()
         else:
             wx.MessageBox(
                 'No profile found in GCode file.\nThis feature only works with GCode files made by Cura 12.07 or newer.',
                 'Profile load error', wx.OK | wx.ICON_INFORMATION)
     dlg.Destroy()
示例#6
0
	def OnSlice(self, e):
		if len(self.filelist) < 1:
			wx.MessageBox('You need to load a file before you can slice 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', '0')
		put('support', 'None')
		#put('machine_center_x', '100')
		#put('machine_center_y', '100')
		#put('retraction_min_travel', '5.0')
		#put('retraction_speed', '13.5')
		#put('retraction_amount', '0.0')
		#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.0)
			put('layer_height', '0.3')
			put('fill_density', '10')
			put('print_speed', '80')
			put('bottom_layer_speed', '40')
		elif self.printTypeHigh.GetValue():
			put('wall_thickness', nozzle_size * 3.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('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')
		
		#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())
		self.SetSize(newSize)
		self.progressPanelList.append(spp)
		
		#Restore the old profile.
		profile.loadGlobalProfileFromString(oldProfile)
示例#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
        #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('machine_center_x', '100')
        #put('machine_center_y', '100')
        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())
        self.SetSize(newSize)
        self.progressPanelList.append(spp)

        #Restore the old profile.
        profile.loadGlobalProfileFromString(oldProfile)
示例#8
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()
		
		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('machine_center_x', item.centerX - self.extruderOffset[item.extruder][0])
				put('machine_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 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.getProfileSettingFloat('machine_center_x')
			action.centerY = profile.getProfileSettingFloat('machine_center_y')
			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)