예제 #1
0
    def _slice(self, stl):
        if not self.cura_pydir in sys.path:
            sys.path.append(self.cura_pydir)

        import Cura
        from Cura.util import sliceEngine
        from Cura.util import objectScene
        from Cura.util import meshLoader

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

        try:
            scene = objectScene.Scene()
            scene.updateMachineDimensions()
            engine = sliceEngine.Engine(commandlineProgressCallback)
            for m in meshLoader.loadMeshes(stl):
                # typeof(m) == printableObjects
                scene.add(m)
            engine.runEngine(scene)
            engine.wait()
        except Exception, e:
            return None
예제 #2
0
    def _slice(self, stl):
        if not self.cura_pydir in sys.path:
            sys.path.append(self.cura_pydir)

        import Cura
        from Cura.util import sliceEngine
        from Cura.util import objectScene
        from Cura.util import meshLoader

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

        try:
            scene = objectScene.Scene()
            scene.updateMachineDimensions()
            engine = sliceEngine.Engine(commandlineProgressCallback)
            for m in meshLoader.loadMeshes(stl):
                # typeof(m) == printableObjects
                scene.add(m)
            engine.runEngine(scene)
            engine.wait()
        except Exception:
            return None

        result = engine.getResult()
        if not result.isFinished():
            return None
        ret = {
            'gcode': result.getGCode(),
            'polygons': result._polygons,
            'filamentUse': result.getFilamentAmount(),
            'printTime': result.getPrintTime(),
        }
        return ret
예제 #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(
        "-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")
    parser.add_option("-o",
                      "--output",
                      action="store",
                      type="string",
                      dest="output",
                      help="path to write sliced file to")

    (options, args) = parser.parse_args()

    profile.loadPreferences(profile.getPreferencePath())
    if options.profile is not None:
        profile.setProfileFromString(options.profile)
    elif options.profileini is not None:
        profile.loadProfile(options.profileini)
    else:
        profile.loadProfile(profile.getDefaultProfilePath())

    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 sliceEngine
        from Cura.util import objectScene
        from Cura.util import meshLoader
        import shutil

        def commandlineProgessCallback(progress, ready):
            if progress >= 0 and not ready:
                print 'Preparing: %d%%' % (progress * 100)

        scene = objectScene.Scene()
        slicer = sliceEngine.Slicer(commandlineProgessCallback)
        for m in meshLoader.loadMeshes(args[0]):
            scene.add(m)
        slicer.runSlicer(scene)
        slicer.wait()

        if options.output:
            shutil.copyfile(slicer.getGCodeFilename(), options.output)
            print 'GCode file saved : %s' % options.output
        else:
            shutil.copyfile(slicer.getGCodeFilename(), args[0] + '.gcode')
            print 'GCode file saved as: %s' % (args[0] + '.gcode')

        slicer.cleanup()
    else:
        from Cura.gui import app
        app.CuraApp(args).MainLoop()
예제 #4
0
def main():
    """
	Main Cura entry point. Parses arguments, and starts GUI or slicing process depending on the arguments.
	"""
    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")
    parser.add_option("-o",
                      "--output",
                      action="store",
                      type="string",
                      dest="output",
                      help="path to write sliced file to")
    parser.add_option("--serialCommunication",
                      action="store",
                      type="string",
                      dest="serialCommunication",
                      help="Start commandline serial monitor")

    (options, args) = parser.parse_args()

    if options.serialCommunication:
        from Cura import serialCommunication
        port, baud = options.serialCommunication.split(':')
        serialCommunication.startMonitor(port, baud)
        return

    print("load preferences from " + profile.getPreferencePath())
    profile.loadPreferences(profile.getPreferencePath())

    if options.profile is not None:
        profile.setProfileFromString(options.profile)
    elif options.profileini is not None:
        profile.loadProfile(options.profileini)
    else:
        profile.loadProfile(profile.getDefaultProfilePath(), True)

    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 sliceEngine
        from Cura.util import objectScene
        from Cura.util import meshLoader
        import shutil

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

        scene = objectScene.Scene()
        scene.updateMachineDimensions()
        engine = sliceEngine.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] + profile.getGCodeExtension()
        with open(options.output, "wb") as f:
            gcode = engine.getResult().getGCode()
            while True:
                data = gcode.read()
                if len(data) == 0:
                    break
                f.write(data)
        print('GCode file saved : %s' % options.output)

        engine.cleanup()
    else:
        from Cura.gui import app
        app.CuraApp(args).MainLoop()
예제 #5
0
	def __init__(self, parent):
		super(SceneView, self).__init__(parent)

		self._yaw = 30
		self._pitch = 60
		self._zoom = 300
		self._scene = objectScene.Scene()
		self._gcode = None
		self._gcodeVBOs = []
		self._gcodeFilename = None
		self._gcodeLoadThread = None
		self._objectShader = None
		self._objectLoadShader = None
		self._focusObj = None
		self._selectedObj = None
		self._objColors = [None,None,None,None]
		self._mouseX = -1
		self._mouseY = -1
		self._mouseState = None
		self._viewTarget = numpy.array([0,0,0], numpy.float32)
		self._animView = None
		self._animZoom = None
		self._platformMesh = meshLoader.loadMeshes(resources.getPathForMesh('ultimaker_platform.stl'))[0]
		self._platformMesh._drawOffset = numpy.array([0,0,2.5], numpy.float32)
		self._isSimpleMode = True

		self._viewport = None
		self._modelMatrix = None
		self._projMatrix = None
		self.tempMatrix = None

		self.openFileButton      = openglGui.glButton(self, 4, 'Load', (0,0), self.showLoadModel)
		self.printButton         = openglGui.glButton(self, 6, 'Print', (1,0), self.OnPrintButton)
		self.printButton.setDisabled(True)

		group = []
		self.rotateToolButton = openglGui.glRadioButton(self, 8, 'Rotate', (0,-1), group, self.OnToolSelect)
		self.scaleToolButton  = openglGui.glRadioButton(self, 9, 'Scale', (1,-1), group, self.OnToolSelect)
		self.mirrorToolButton  = openglGui.glRadioButton(self, 10, 'Mirror', (2,-1), group, self.OnToolSelect)

		self.resetRotationButton = openglGui.glButton(self, 12, 'Reset', (0,-2), self.OnRotateReset)
		self.layFlatButton       = openglGui.glButton(self, 16, 'Lay flat', (0,-3), self.OnLayFlat)

		self.resetScaleButton    = openglGui.glButton(self, 13, 'Reset', (1,-2), self.OnScaleReset)
		self.scaleMaxButton      = openglGui.glButton(self, 17, 'To max', (1,-3), self.OnScaleMax)

		self.mirrorXButton       = openglGui.glButton(self, 14, 'Mirror X', (2,-2), lambda button: self.OnMirror(0))
		self.mirrorYButton       = openglGui.glButton(self, 18, 'Mirror Y', (2,-3), lambda button: self.OnMirror(1))
		self.mirrorZButton       = openglGui.glButton(self, 22, 'Mirror Z', (2,-4), lambda button: self.OnMirror(2))

		self.rotateToolButton.setExpandArrow(True)
		self.scaleToolButton.setExpandArrow(True)
		self.mirrorToolButton.setExpandArrow(True)

		self.scaleForm = openglGui.glFrame(self, (2, -2))
		openglGui.glGuiLayoutGrid(self.scaleForm)
		openglGui.glLabel(self.scaleForm, 'Scale X', (0,0))
		self.scaleXctrl = openglGui.glNumberCtrl(self.scaleForm, '1.0', (1,0), lambda value: self.OnScaleEntry(value, 0))
		openglGui.glLabel(self.scaleForm, 'Scale Y', (0,1))
		self.scaleYctrl = openglGui.glNumberCtrl(self.scaleForm, '1.0', (1,1), lambda value: self.OnScaleEntry(value, 1))
		openglGui.glLabel(self.scaleForm, 'Scale Z', (0,2))
		self.scaleZctrl = openglGui.glNumberCtrl(self.scaleForm, '1.0', (1,2), lambda value: self.OnScaleEntry(value, 2))
		openglGui.glLabel(self.scaleForm, 'Size X (mm)', (0,4))
		self.scaleXmmctrl = openglGui.glNumberCtrl(self.scaleForm, '0.0', (1,4), lambda value: self.OnScaleEntryMM(value, 0))
		openglGui.glLabel(self.scaleForm, 'Size Y (mm)', (0,5))
		self.scaleYmmctrl = openglGui.glNumberCtrl(self.scaleForm, '0.0', (1,5), lambda value: self.OnScaleEntryMM(value, 1))
		openglGui.glLabel(self.scaleForm, 'Size Z (mm)', (0,6))
		self.scaleZmmctrl = openglGui.glNumberCtrl(self.scaleForm, '0.0', (1,6), lambda value: self.OnScaleEntryMM(value, 2))
		openglGui.glLabel(self.scaleForm, 'Uniform scale', (0,8))
		self.scaleUniform = openglGui.glCheckbox(self.scaleForm, True, (1,8), None)

		self.viewSelection = openglGui.glComboButton(self, 'View mode', [7,19,11,15,23], ['Normal', 'Overhang', 'Transparent', 'X-Ray', 'Layers'], (-1,0), self.OnViewChange)
		self.layerSelect = openglGui.glSlider(self, 10000, 0, 1, (-1,-2), lambda : self.QueueRefresh())

		self.notification = openglGui.glNotification(self, (0, 0))

		self._slicer = sliceEngine.Slicer(self._updateSliceProgress)
		self._sceneUpdateTimer = wx.Timer(self)
		self.Bind(wx.EVT_TIMER, self._onRunSlicer, self._sceneUpdateTimer)
		self.Bind(wx.EVT_MOUSEWHEEL, self.OnMouseWheel)
		self.Bind(wx.EVT_LEAVE_WINDOW, self.OnMouseLeave)

		self.OnViewChange()
		self.OnToolSelect(0)
		self.updateToolButtons()
		self.updateProfileToControls()