mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-07-23 03:34:27 +08:00
add preamble to gcode processor if using start_gcode_manual
https://github.com/supermerill/SuperSlicer#1172
This commit is contained in:
parent
ee0b73ecdc
commit
f4ae8c869d
@ -719,6 +719,11 @@ void GCode::do_export(Print* print, const char* path, GCodeProcessor::Result* re
|
||||
}
|
||||
|
||||
BOOST_LOG_TRIVIAL(debug) << "Start processing gcode, " << log_memory_info();
|
||||
//klipper can hide gcode into a macro, so add guessed init gcode to the processor.
|
||||
if (this->config().start_gcode_manual) {
|
||||
std::string gcode = m_writer.preamble();
|
||||
m_processor.process_string(gcode, [print]() { print->throw_if_canceled(); });
|
||||
}
|
||||
m_processor.process_file(path_tmp, true, [print]() { print->throw_if_canceled(); });
|
||||
DoExport::update_print_estimated_times_stats(m_processor, print->m_print_statistics);
|
||||
if (result != nullptr)
|
||||
|
@ -842,6 +842,15 @@ void GCodeProcessor::reset()
|
||||
m_width_compare.reset();
|
||||
#endif // ENABLE_GCODE_VIEWER_DATA_CHECKING
|
||||
}
|
||||
void GCodeProcessor::process_string(const std::string& gcode, std::function<void()> cancel_callback)
|
||||
{
|
||||
std::stringstream ss(gcode);
|
||||
std::string strline;
|
||||
while ( std::getline(ss, strline))
|
||||
m_parser.parse_line(strline, [this](GCodeReader& reader, const GCodeReader::GCodeLine& line) {
|
||||
process_gcode_line(line);
|
||||
});
|
||||
}
|
||||
|
||||
void GCodeProcessor::process_file(const std::string& filename, bool apply_postprocess, std::function<void()> cancel_callback)
|
||||
{
|
||||
|
@ -479,6 +479,7 @@ namespace Slic3r {
|
||||
// Process the gcode contained in the file with the given filename
|
||||
// throws CanceledException through print->throw_if_canceled() (sent by the caller as callback).
|
||||
void process_file(const std::string& filename, bool apply_postprocess, std::function<void()> cancel_callback = nullptr);
|
||||
void process_string(const std::string& gcode, std::function<void()> cancel_callback = nullptr);
|
||||
|
||||
float get_time(PrintEstimatedTimeStatistics::ETimeMode mode) const;
|
||||
std::string get_time_dhm(PrintEstimatedTimeStatistics::ETimeMode mode) const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user