Пример #1
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 is not None:
		profile.loadGlobalProfileFromString(options.profile)
	if options.profileini is not None:
		profile.loadGlobalProfile(options.profileini)

	if options.openprojectplanner is not None:
		from Cura.gui import projectPlanner
		projectPlanner.main()
	elif options.openflatslicer is not None:
		from Cura.gui import flatSlicerWindow
		flatSlicerWindow.main()
	elif options.printfile is not None:
		from Cura.gui import printWindow
		printWindow.startPrintInterface(options.printfile)
	elif options.slice is not None:
		from Cura.util import sliceRun
		sliceRun.runSlice(args)
	else:
		if len(args) > 0:
			profile.putPreference('lastFile', ';'.join(args))

		import wx._core
		from Cura.gui import splashScreen

		class CuraApp(wx.App):
			def MacOpenFile(self, path):
				try:
					pass
				except Exception as e:
					warnings.warn("File at {p} cannot be read: {e}".format(p=path, e=str(e)))

		def mainWindowRunCallback(splash):
			from Cura.gui import mainWindow
			if splash is not None:
				splash.Show(False)
			mainWindow.main()

		app = CuraApp(False)
		# Apple discourages usage of splash screens on a mac.
		if sys.platform.startswith('darwin'):
			mainWindowRunCallback(None)
		else:
			splashScreen.splashScreen(mainWindowRunCallback)
		app.MainLoop()
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("-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 is not None:
		profile.loadGlobalProfileFromString(options.profile)
	if options.profileini is not None:
		profile.loadGlobalProfile(options.profileini)

	if options.printfile is not None:
		from Cura.gui import printWindow
		printWindow.startPrintInterface(options.printfile)
	elif options.slice is not None:
		from Cura.util import sliceRun
		sliceRun.runSlice(args)
	else:
		#Place any unused arguments as last file, so Cura starts with opening those files.
		if len(args) > 0:
			profile.putPreference('lastFile', '^ '.join(args))

		#Do not import anything from Cura.gui before this spot, as the above code also needs to run in pypy.
		from Cura.gui import app
		app.CuraApp(args).MainLoop()
Пример #3
0
	def OnLoadProfile(self, e):
		dlg=wx.FileDialog(self, "Select profile file to load", os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST)
		dlg.SetWildcard("ini files (*.ini)|*.ini")
		if dlg.ShowModal() == wx.ID_OK:
			profileFile = dlg.GetPath()
			profile.loadGlobalProfile(profileFile)
			self.updateProfileToControls()
		dlg.Destroy()
Пример #4
0
	def OnProfileMRU(self, e):
		fileNum = e.GetId() - self.ID_MRU_PROFILE1
		path = self.profileFileHistory.GetHistoryFile(fileNum)
		# Update Profile MRU
		self.profileFileHistory.AddFileToHistory(path)  # move up the list
		self.config.SetPath("/ProfileMRU")
		self.profileFileHistory.Save(self.config)
		self.config.Flush()
		# Load Profile	
		profile.loadGlobalProfile(path)
		self.updateProfileToControls()
Пример #5
0
 def OnProfileMRU(self, e):
     fileNum = e.GetId() - self.ID_MRU_PROFILE1
     path = self.profileFileHistory.GetHistoryFile(fileNum)
     # Update Profile MRU
     self.profileFileHistory.AddFileToHistory(path)  # move up the list
     self.config.SetPath("/ProfileMRU")
     self.profileFileHistory.Save(self.config)
     self.config.Flush()
     # Load Profile
     profile.loadGlobalProfile(path)
     self.updateProfileToControls()
Пример #6
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(
        "-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 is not None:
        profile.loadGlobalProfileFromString(options.profile)
    if options.profileini is not None:
        profile.loadGlobalProfile(options.profileini)

    if options.printfile is not None:
        from Cura.gui import printWindow
        printWindow.startPrintInterface(options.printfile)
    elif options.slice is not None:
        from Cura.util import sliceRun
        sliceRun.runSlice(args)
    else:
        #Place any unused arguments as last file, so Cura starts with opening those files.
        if len(args) > 0:
            profile.putPreference('lastFile', ';'.join(args))
            profile.putProfileSetting('model_matrix', '1,0,0,0,1,0,0,0,1')
            profile.setPluginConfig([])

        #Do not import anything from Cura.gui before this spot, as the above code also needs to run in pypy.
        from Cura.gui import app
        app.CuraApp().MainLoop()
Пример #7
0
    def OnLoadProfile(self, e):
        dlg = wx.FileDialog(self,
                            "Select profile file to load",
                            os.path.split(
                                profile.getPreference('lastFile'))[0],
                            style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
        dlg.SetWildcard("ini files (*.ini)|*.ini")
        if dlg.ShowModal() == wx.ID_OK:
            profileFile = dlg.GetPath()
            profile.loadGlobalProfile(profileFile)
            self.updateProfileToControls()

            # Update the Profile MRU
            self.addToProfileMRU(profileFile)
        dlg.Destroy()
	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 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("-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="append", 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")
	parser.add_option("-o", "--output", action="store", type="string", dest="output",
		help="path to write sliced file to")

	(options, args) = parser.parse_args()

	# if options.profile is not None:
	# 	profile.loadGlobalProfileFromString(options.profile)
	if options.profile is not None:
		for option in options.profile:
			(setting, arg) = option.split("=")
			profile.putProfileSetting(setting, arg)

	if options.profileini is not None:
		profile.loadGlobalProfile(options.profileini)

	if options.printfile is not None:
		from Cura.gui import printWindow
		printWindow.startPrintInterface(options.printfile)
	elif options.slice is not None:
		from Cura.util import sliceEngine2
		from Cura.util import objectScene
		from Cura.util import meshLoader
		from Cura.util import resources
		from Cura.util import version
		brand = version.getBrand()
		resources.setupLocalization(brand)

		def commandlineProgressCallback(progress):
			if progress >= 0:
				print 'Preparing: %d%%' % (progress * 100)
				pass

		scene = objectScene.Scene()
		engine = sliceEngine2.Engine(commandlineProgressCallback)

		for m in meshLoader.loadMeshes(args[0]):
			scene.add(m)
		engine.runEngine(scene)
		engine.wait()

		if not options.output:
			options.output = args[0] + '.gcode'
		with open(options.output, "wb") as f:
			gcode = engine.getResult().getGCode()
			while True:
				data = gcode.read()
				if len(data) == 0:
					break
				f.write(data)
		engine.cleanup()

		# from Cura.util import sliceRun
		# sliceRun.runSlice(args)
	else:
		#Place any unused arguments as last file, so Cura starts with opening those files.
		if len(args) > 0:
			profile.putPreference('lastFile', '^ '.join(args))

		#Do not import anything from Cura.gui before this spot, as the above code also needs to run in pypy.
		from Cura.gui import app
		app.CuraApp(args).MainLoop()
Пример #10
0
	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