def runSlicer(self, scene): extruderCount = 1 for obj in scene.objects(): if scene.checkPlatform(obj): extruderCount = max(extruderCount, len(obj._meshList)) if profile.getProfileSetting("support_dual_extrusion") == "Second extruder": extruderCount = max(extruderCount, 2) commandList = [getEngineFilename(), "-vv"] for k, v in self._engineSettings(extruderCount).iteritems(): commandList += ["-s", "%s=%s" % (k, str(v))] commandList += ["-o", self._exportFilename] commandList += ["-b", self._binaryStorageFilename] self._objCount = 0 with open(self._binaryStorageFilename, "wb") as f: hash = hashlib.sha512() order = scene.printOrder() if order is None: pos = numpy.array(profile.getMachineCenterCoords()) * 1000 commandList += ["-s", "posx=%d" % int(pos[0]), "-s", "posy=%d" % int(pos[1])] vertexTotal = 0 for obj in scene.objects(): if scene.checkPlatform(obj): for mesh in obj._meshList: vertexTotal += mesh.vertexCount f.write(numpy.array([vertexTotal], numpy.int32).tostring()) for obj in scene.objects(): if scene.checkPlatform(obj): for mesh in obj._meshList: vertexes = ( numpy.matrix(mesh.vertexes, copy=False) * numpy.matrix(obj._matrix, numpy.float32) ).getA() vertexes -= obj._drawOffset vertexes += numpy.array([obj.getPosition()[0], obj.getPosition()[1], 0.0]) f.write(vertexes.tostring()) hash.update(mesh.vertexes.tostring()) commandList += ["#"] self._objCount = 1 else: for n in order: obj = scene.objects()[n] for mesh in obj._meshList: f.write(numpy.array([mesh.vertexCount], numpy.int32).tostring()) s = mesh.vertexes.tostring() f.write(s) hash.update(s) pos = obj.getPosition() * 1000 pos += numpy.array(profile.getMachineCenterCoords()) * 1000 commandList += ["-m", ",".join(map(str, obj._matrix.getA().flatten()))] commandList += ["-s", "posx=%d" % int(pos[0]), "-s", "posy=%d" % int(pos[1])] commandList += ["#" * len(obj._meshList)] self._objCount += 1 self._modelHash = hash.hexdigest() if self._objCount > 0: self._thread = threading.Thread(target=self._watchProcess, args=(commandList, self._thread)) self._thread.daemon = True self._thread.start()
def runSlicer(self, scene): extruderCount = 1 for obj in scene.objects(): if scene.checkPlatform(obj): extruderCount = max(extruderCount, len(obj._meshList)) commandList = [getEngineFilename(), '-vv'] for k, v in self._engineSettings(extruderCount).iteritems(): commandList += ['-s', '%s=%s' % (k, str(v))] commandList += ['-o', self._exportFilename] commandList += ['-b', self._binaryStorageFilename] self._objCount = 0 with open(self._binaryStorageFilename, "wb") as f: hash = hashlib.sha512() order = scene.printOrder() if order is None: pos = numpy.array(profile.getMachineCenterCoords()) * 1000 commandList += ['-s', 'posx=%d' % int(pos[0]), '-s', 'posy=%d' % int(pos[1])] vertexTotal = 0 for obj in scene.objects(): if scene.checkPlatform(obj): for mesh in obj._meshList: vertexTotal += mesh.vertexCount f.write(numpy.array([vertexTotal], numpy.int32).tostring()) for obj in scene.objects(): if scene.checkPlatform(obj): for mesh in obj._meshList: vertexes = (numpy.matrix(mesh.vertexes, copy = False) * numpy.matrix(obj._matrix, numpy.float32)).getA() vertexes -= obj._drawOffset vertexes += numpy.array([obj.getPosition()[0], obj.getPosition()[1], 0.0]) f.write(vertexes.tostring()) hash.update(mesh.vertexes.tostring()) commandList += ['#'] self._objCount = 1 else: for n in order: obj = scene.objects()[n] for mesh in obj._meshList: f.write(numpy.array([mesh.vertexCount], numpy.int32).tostring()) s = mesh.vertexes.tostring() f.write(s) hash.update(s) pos = obj.getPosition() * 1000 pos += numpy.array(profile.getMachineCenterCoords()) * 1000 commandList += ['-m', ','.join(map(str, obj._matrix.getA().flatten()))] commandList += ['-s', 'posx=%d' % int(pos[0]), '-s', 'posy=%d' % int(pos[1])] commandList += ['#' * len(obj._meshList)] self._objCount += 1 self._modelHash = hash.hexdigest() if self._objCount > 0: self._thread = threading.Thread(target=self._watchProcess, args=(commandList, self._thread)) self._thread.daemon = True self._thread.start()
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() if self.printMode == 0: fileList = [] positionList = [] for item in self.list: fileList.append(item.filename) positionList.append( [item.centerX, item.centerY] + (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)
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)
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)
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)
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)
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)
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 runEngine(self, scene): if len(scene.objects()) < 1: return extruderCount = 1 for obj in scene.objects(): if scene.checkPlatform(obj): extruderCount = max(extruderCount, len(obj._meshList)) extruderCount = max(extruderCount, profile.minimalExtruderCount()) commandList = [getEngineFilename(), '-v', '-p'] for k, v in self._engineSettings(extruderCount).iteritems(): commandList += ['-s', '%s=%s' % (k, str(v))] commandList += ['-g', '%d' % (self._serverPortNr)] self._objCount = 0 engineModelData = [] hash = hashlib.sha512() order = scene.printOrder() if order is None: pos = numpy.array(profile.getMachineCenterCoords()) * 1000 objMin = None objMax = None for obj in scene.objects(): if scene.checkPlatform(obj): oMin = obj.getMinimum()[0:2] + obj.getPosition() oMax = obj.getMaximum()[0:2] + obj.getPosition() if objMin is None: objMin = oMin objMax = oMax else: objMin[0] = min(oMin[0], objMin[0]) objMin[1] = min(oMin[1], objMin[1]) objMax[0] = max(oMax[0], objMax[0]) objMax[1] = max(oMax[1], objMax[1]) if objMin is None: return pos += (objMin + objMax) / 2.0 * 1000 commandList += [ '-s', 'posx=%d' % int(pos[0]), '-s', 'posy=%d' % int(pos[1]) ] vertexTotal = [0] * 4 meshMax = 1 for obj in scene.objects(): if scene.checkPlatform(obj): meshMax = max(meshMax, len(obj._meshList)) for n in xrange(0, len(obj._meshList)): vertexTotal[n] += obj._meshList[n].vertexCount for n in xrange(0, meshMax): verts = numpy.zeros((0, 3), numpy.float32) for obj in scene.objects(): if scene.checkPlatform(obj): if n < len(obj._meshList): vertexes = (numpy.matrix(obj._meshList[n].vertexes, copy=False) * numpy.matrix(obj._matrix, numpy.float32)).getA() vertexes -= obj._drawOffset vertexes += numpy.array([ obj.getPosition()[0], obj.getPosition()[1], 0.0 ]) verts = numpy.concatenate((verts, vertexes)) hash.update(obj._meshList[n].vertexes.tostring()) engineModelData.append((vertexTotal[n], verts)) commandList += ['$' * meshMax] self._objCount = 1 else: for n in order: obj = scene.objects()[n] for mesh in obj._meshList: engineModelData.append((mesh.vertexCount, mesh.vertexes)) hash.update(mesh.vertexes.tostring()) pos = obj.getPosition() * 1000 pos += numpy.array(profile.getMachineCenterCoords()) * 1000 commandList += [ '-m', ','.join(map(str, obj._matrix.getA().flatten())) ] commandList += [ '-s', 'posx=%d' % int(pos[0]), '-s', 'posy=%d' % int(pos[1]) ] commandList += ['$' * len(obj._meshList)] self._objCount += 1 modelHash = hash.hexdigest() if self._objCount > 0: self._modelData = engineModelData self._thread = threading.Thread(target=self._watchProcess, args=(commandList, self._thread, modelHash)) self._thread.daemon = True self._thread.start()
def runSlicer(self, scene): extruderCount = 1 for obj in scene.objects(): if scene.checkPlatform(obj): extruderCount = max(extruderCount, len(obj._meshList)) if profile.getProfileSetting('support_dual_extrusion') == 'Second extruder': extruderCount = max(extruderCount, 2) commandList = [getEngineFilename(), '-vv'] for k, v in self._engineSettings(extruderCount).iteritems(): commandList += ['-s', '%s=%s' % (k, str(v))] commandList += ['-o', self._exportFilename] commandList += ['-b', self._binaryStorageFilename] self._objCount = 0 with open(self._binaryStorageFilename, "wb") as f: hash = hashlib.sha512() order = scene.printOrder() if order is None: pos = numpy.array(profile.getMachineCenterCoords()) * 1000 objMin = None objMax = None for obj in scene.objects(): if scene.checkPlatform(obj): oMin = obj.getMinimum()[0:2] + obj.getPosition() oMax = obj.getMaximum()[0:2] + obj.getPosition() if objMin is None: objMin = oMin objMax = oMax else: objMin[0] = min(oMin[0], objMin[0]) objMin[1] = min(oMin[1], objMin[1]) objMax[0] = max(oMax[0], objMax[0]) objMax[1] = max(oMax[1], objMax[1]) pos += (objMin + objMax) / 2.0 * 1000 commandList += ['-s', 'posx=%d' % int(pos[0]), '-s', 'posy=%d' % int(pos[1])] vertexTotal = 0 for obj in scene.objects(): if scene.checkPlatform(obj): for mesh in obj._meshList: vertexTotal += mesh.vertexCount f.write(numpy.array([vertexTotal], numpy.int32).tostring()) for obj in scene.objects(): if scene.checkPlatform(obj): for mesh in obj._meshList: vertexes = (numpy.matrix(mesh.vertexes, copy = False) * numpy.matrix(obj._matrix, numpy.float32)).getA() vertexes -= obj._drawOffset vertexes += numpy.array([obj.getPosition()[0], obj.getPosition()[1], 0.0]) f.write(vertexes.tostring()) hash.update(mesh.vertexes.tostring()) commandList += ['#'] self._objCount = 1 else: for n in order: obj = scene.objects()[n] for mesh in obj._meshList: f.write(numpy.array([mesh.vertexCount], numpy.int32).tostring()) s = mesh.vertexes.tostring() f.write(s) hash.update(s) pos = obj.getPosition() * 1000 pos += numpy.array(profile.getMachineCenterCoords()) * 1000 commandList += ['-m', ','.join(map(str, obj._matrix.getA().flatten()))] commandList += ['-s', 'posx=%d' % int(pos[0]), '-s', 'posy=%d' % int(pos[1])] commandList += ['#' * len(obj._meshList)] self._objCount += 1 self._modelHash = hash.hexdigest() if self._objCount > 0: self._thread = threading.Thread(target=self._watchProcess, args=(commandList, self._thread)) self._thread.daemon = True self._thread.start()
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)