@@ -4394,6 +4394,10 @@ GCodeResult GCodes::LoadFilament(GCodeBuffer& gb, const StringRef& reply) THROWS
43944394 return GCodeResult::error;
43954395 }
43964396
4397+ bool seen = false ;
4398+ bool runMacro = true ;
4399+ gb.TryGetBValue (' P' , runMacro, seen);
4400+
43974401 if (gb.Seen (' S' ))
43984402 {
43994403 String<FilamentNameLength> filamentName;
@@ -4422,7 +4426,10 @@ GCodeResult GCodes::LoadFilament(GCodeBuffer& gb, const StringRef& reply) THROWS
44224426
44234427 String<StringLength256> scratchString;
44244428 scratchString.printf (" %s%s/%s" , FILAMENTS_DIRECTORY, filamentName.c_str (), LOAD_FILAMENT_G);
4425- DoFileMacro (gb, scratchString.c_str (), true , SystemHelperMacroCode);
4429+ if (runMacro)
4430+ {
4431+ DoFileMacro (gb, scratchString.c_str (), true , SystemHelperMacroCode);
4432+ }
44264433 }
44274434 else if (tool->GetFilament ()->IsLoaded ())
44284435 {
@@ -4451,12 +4458,19 @@ GCodeResult GCodes::UnloadFilament(GCodeBuffer& gb, const StringRef& reply) THRO
44514458 return GCodeResult::error;
44524459 }
44534460
4461+ bool seen = false ;
4462+ bool runMacro = true ;
4463+ gb.TryGetBValue (' P' , runMacro, seen);
4464+
44544465 if (tool->GetFilament ()->IsLoaded ()) // if no filament is loaded, nothing to do
44554466 {
44564467 gb.SetState (GCodeState::unloadingFilament);
44574468 String<StringLength256> scratchString;
44584469 scratchString.printf (" %s%s/%s" , FILAMENTS_DIRECTORY, tool->GetFilament ()->GetName (), UNLOAD_FILAMENT_G);
4459- DoFileMacro (gb, scratchString.c_str (), true , SystemHelperMacroCode);
4470+ if (runMacro)
4471+ {
4472+ DoFileMacro (gb, scratchString.c_str (), true , SystemHelperMacroCode);
4473+ }
44604474 }
44614475 return GCodeResult::ok;
44624476}
0 commit comments