void SliceEv(Slicer.eSliceEvent ev, int layer, int totallayers, SliceFile sf) { String path = ""; String fileName = ""; switch (ev) { case Slicer.eSliceEvent.eSliceStarted: break; case Slicer.eSliceEvent.eLayerSliced: break; case Slicer.eSliceEvent.eSliceCompleted: // this all needs to be changed.... m_slicefile = sf; //generate the GCode m_gcode = GCodeGenerator.Generate(m_slicefile, m_printerinfo); path = SliceFile.GetSliceFilePath(m_slicefile.modelname); fileName = Path.GetFileNameWithoutExtension(m_slicefile.modelname) + ".gcode"; //see if we're exporting this to a zip file if (sf.m_config.m_exportopt.Contains("ZIP") && sf.m_config.export) { // open the existing zip file //store the gcode Stream stream = new MemoryStream(System.Text.Encoding.ASCII.GetBytes(m_gcode.RawGCode)); String zpath = path + ".zip"; if (!Utility.StoreInZip(zpath, fileName, stream)) { DebugLogger.Instance().LogError("Could not store GCode in Zip " + zpath); } } else // or just to the disk { String sdn = path + UVDLPApp.m_pathsep + fileName; SaveGCode(sdn); } //save the slicer object for later too //save the slice file // UVDLPApp.Instance().m_slicefile.Save(path + UVDLPApp.m_pathsep + fn + ".sliced"); break; case Slicer.eSliceEvent.eSliceCancelled: DebugLogger.Instance().LogRecord("Slicing Cancelled"); break; } }
void SliceEv(Slicer.eSliceEvent ev, int layer, int totallayers, SliceFile sf) { // String path = ""; // String fileName = ""; switch (ev) { case Slicer.eSliceEvent.eSliceStarted: break; case Slicer.eSliceEvent.eLayerSliced: break; case Slicer.eSliceEvent.eSliceCompleted: // this all needs to be changed.... m_slicefile = sf; //generate the GCode m_gcode = GCodeGenerator.Generate(m_slicefile, m_printerinfo); //we only need the file name of the gcode if we're saving it somewhere... //see if we're exporting this to a zip file //if (sf.m_config.m_exportopt.Contains("ZIP") && sf.m_config.export) if (sf.m_config.export) { // open the existing scene file //store the gcode MemoryStream stream = new MemoryStream(System.Text.Encoding.ASCII.GetBytes(m_gcode.RawGCode)); String gcn = Path.GetFileNameWithoutExtension(UVDLPApp.Instance().SceneFileName) + ".gcode"; //SceneFile.Instance().RemoveExistingGCode(UVDLPApp.Instance().SceneFileName); SceneFile.Instance().RemoveResourcesFromFile(UVDLPApp.Instance().SceneFileName, "GCode", ".gcode"); SceneFile.Instance().AddGCodeToFile(UVDLPApp.Instance().SceneFileName, stream, gcn); } //save the slicer object for later too //save the slice file // UVDLPApp.Instance().m_slicefile.Save(path + UVDLPApp.m_pathsep + fn + ".sliced"); break; case Slicer.eSliceEvent.eSliceCancelled: DebugLogger.Instance().LogRecord("Slicing Cancelled"); break; } }
void SliceEv(Slicer.eSliceEvent ev, int layer, int totallayers) { String path = ""; switch (ev) { case Slicer.eSliceEvent.eSliceStarted: // if we're exporting images if (m_buildparms.exportimages) { // get the model name String modelname = m_obj.m_fullname; // strip off the file extension path = Path.GetDirectoryName(modelname); path += UVDLPApp.m_pathsep; path += Path.GetFileNameWithoutExtension(modelname); // strip off the file extension if (!Directory.Exists(path)) // check and see if a directory of that name exists, { Directory.CreateDirectory(path); // if not, create it } } break; case Slicer.eSliceEvent.eLayerSliced: //save the rendered image slice //render the slice if (m_buildparms.exportimages) { // get the model name String modelname = m_obj.m_fullname; // strip off the file extension path = Path.GetDirectoryName(modelname); path += UVDLPApp.m_pathsep; path += Path.GetFileNameWithoutExtension(modelname); // strip off the file extension Bitmap bmp = null; String imagename = path + m_pathsep + Path.GetFileNameWithoutExtension(modelname) + String.Format("{0:0000}", layer) + ".png"; bmp = UVDLPApp.Instance().m_slicefile.RenderSlice(layer); bmp.Save(imagename); } break; case Slicer.eSliceEvent.eSliceCompleted: m_gcode = GCodeGenerator.Generate(m_slicefile, m_printerinfo); /* * //get the path of the current object file * path = Path.GetDirectoryName(m_obj.m_fullname); * string fn = Path.GetFileNameWithoutExtension(m_obj.m_fullname); * if (!UVDLPApp.Instance().m_gcode.Save(path + UVDLPApp.m_pathsep + fn + ".gcode")) * { * DebugLogger.Instance().LogRecord("Cannot save GCode File " + path + m_pathsep + fn + ".gcode"); * } * */ SaveGCode(); break; case Slicer.eSliceEvent.eSliceCancelled: DebugLogger.Instance().LogRecord("Slicing Cancelled"); break; } }
void SliceEv(Slicer.eSliceEvent ev, int layer, int totallayers) { String path = ""; switch (ev) { case Slicer.eSliceEvent.eSliceStarted: // if we're exporting images if (m_buildparms.exportimages) { m_zip = new ZipFile(); // get the model name, could be scene.... String modelname = m_selectedobject.m_fullname; // strip off the file extension path = Path.GetDirectoryName(modelname); path += UVDLPApp.m_pathsep; path += Path.GetFileNameWithoutExtension(modelname); // strip off the file extension if (!Directory.Exists(path)) // check and see if a directory of that name exists, { Directory.CreateDirectory(path); // if not, create it } } break; case Slicer.eSliceEvent.eLayerSliced: //save the rendered image slice //render the slice if (m_buildparms.exportimages) { // get the model name String modelname = m_selectedobject.m_fullname; // strip off the file extension path = Path.GetDirectoryName(modelname); path += UVDLPApp.m_pathsep; path += Path.GetFileNameWithoutExtension(modelname); // strip off the file extension Bitmap bmp = null; String imname = Path.GetFileNameWithoutExtension(modelname) + String.Format("{0:0000}", layer) + ".png"; String imagename = path + m_pathsep + imname; bmp = UVDLPApp.Instance().m_slicefile.RenderSlice(layer); // bmp.Save(imagename); // create a memory stream for this to save into MemoryStream ms = new MemoryStream(); bmp.Save(ms, ImageFormat.Png); ms.Seek(0, SeekOrigin.Begin); // seek back to beginning m_zip.AddEntry(imname, ms); } break; case Slicer.eSliceEvent.eSliceCompleted: // save the zip file full of images if (m_buildparms.exportimages) { String modelname = m_selectedobject.m_fullname; // strip off the file extension path = Path.GetDirectoryName(modelname); path += UVDLPApp.m_pathsep; path += Path.GetFileNameWithoutExtension(modelname); // strip off the file extension path += ".zip"; m_zip.Save(path); } m_gcode = GCodeGenerator.Generate(m_slicefile, m_printerinfo); //get the path of the current object file path = Path.GetDirectoryName(m_selectedobject.m_fullname); string fn = Path.GetFileNameWithoutExtension(m_selectedobject.m_fullname); /* * if (!UVDLPApp.Instance().m_gcode.Save(path + UVDLPApp.m_pathsep + fn + ".gcode")) * { * DebugLogger.Instance().LogRecord("Cannot save GCode File " + path + m_pathsep + fn + ".gcode"); * } */ SaveGCode(path + UVDLPApp.m_pathsep + fn + ".gcode"); break; case Slicer.eSliceEvent.eSliceCancelled: DebugLogger.Instance().LogRecord("Slicing Cancelled"); break; } }