mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-30 20:21:12 -06:00 
			
		
		
		
	SS port - Change extrusion role gcode (#2459)
implement custom gcode for when the extrusion role is changed Co-authored-by: supermerill <merill@free.fr>
This commit is contained in:
		
							parent
							
								
									1b53d1b72d
								
							
						
					
					
						commit
						120a3576a0
					
				
					 6 changed files with 66 additions and 1 deletions
				
			
		|  | @ -1402,6 +1402,8 @@ namespace DoExport { | |||
|         //BBS
 | ||||
|         //if (ret.size() < MAX_TAGS_COUNT) check(_(L("Printing by object G-code")), config.printing_by_object_gcode.value);
 | ||||
|         //if (ret.size() < MAX_TAGS_COUNT) check(_(L("Color Change G-code")), config.color_change_gcode.value);
 | ||||
|         //Orca
 | ||||
|         if (ret.size() < MAX_TAGS_COUNT) check(_(L("Change extrusion role G-code")), config.change_extrusion_role_gcode.value); | ||||
|         if (ret.size() < MAX_TAGS_COUNT) check(_(L("Pause G-code")), config.machine_pause_gcode.value); | ||||
|         if (ret.size() < MAX_TAGS_COUNT) check(_(L("Template Custom G-code")), config.template_custom_gcode.value); | ||||
|         if (ret.size() < MAX_TAGS_COUNT) { | ||||
|  | @ -4755,6 +4757,18 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description, | |||
| 
 | ||||
|     double F = speed * 60;  // convert mm/sec to mm/min
 | ||||
| 
 | ||||
|     //Orca: process custom gcode for extrusion role change
 | ||||
|     if (path.role() != m_last_extrusion_role && !m_config.change_extrusion_role_gcode.value.empty()) { | ||||
|             DynamicConfig config; | ||||
|             config.set_key_value("extrusion_role", new ConfigOptionString(extrusion_role_to_string_for_parser(path.role()))); | ||||
|             config.set_key_value("last_extrusion_role", new ConfigOptionString(extrusion_role_to_string_for_parser(m_last_extrusion_role))); | ||||
|             config.set_key_value("layer_num", new ConfigOptionInt(m_layer_index + 1)); | ||||
|             config.set_key_value("layer_z", new ConfigOptionFloat(m_layer == nullptr ? m_last_height : m_layer->print_z)); | ||||
|             gcode += this->placeholder_parser_process("change_extrusion_role_gcode", | ||||
|                                                       m_config.change_extrusion_role_gcode.value, m_writer.extruder()->id(), &config) | ||||
|                      + "\n"; | ||||
|     } | ||||
| 
 | ||||
|     // extrude arc or line
 | ||||
|     if (m_enable_extrusion_role_markers) { | ||||
|         if (path.role() != m_last_extrusion_role) { | ||||
|  | @ -5002,6 +5016,35 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description, | |||
|     return gcode; | ||||
| } | ||||
| 
 | ||||
| //Orca: get string name of extrusion role. used for change_extruder_role_gcode
 | ||||
| std::string GCode::extrusion_role_to_string_for_parser(const ExtrusionRole & role) | ||||
| { | ||||
|     switch (role) { | ||||
|         case erPerimeter: return "Perimeter"; | ||||
|         case erExternalPerimeter: return "ExternalPerimeter"; | ||||
|         case erOverhangPerimeter: return "OverhangPerimeter"; | ||||
|         case erInternalInfill: return "InternalInfill"; | ||||
|         case erSolidInfill: return "SolidInfill"; | ||||
|         case erTopSolidInfill: return "TopSolidInfill"; | ||||
|         case erBottomSurface: return "BottomSurface"; | ||||
|         case erBridgeInfill: | ||||
|         case erInternalBridgeInfill: return "BridgeInfill"; | ||||
|         case erGapFill: return "GapFill"; | ||||
|         case erIroning: return "Ironing"; | ||||
|         case erSkirt: return "Skirt"; | ||||
|         case erBrim: return "Brim"; | ||||
|         case erSupportMaterial: return "SupportMaterial"; | ||||
|         case erSupportMaterialInterface: return "SupportMaterialInterface"; | ||||
|         case erSupportTransition: return "SupportTransition"; | ||||
|         case erWipeTower: return "WipeTower"; | ||||
|         case erCustom: | ||||
|         case erMixed: | ||||
|         case erCount: | ||||
|         case erNone: | ||||
|         default: return "Mixed"; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| std::string encodeBase64(uint64_t value) | ||||
| { | ||||
|     //Always use big endian mode
 | ||||
|  |  | |||
|  | @ -205,6 +205,7 @@ public: | |||
|     // inside the generated string and after the G-code export finishes.
 | ||||
|     std::string     placeholder_parser_process(const std::string &name, const std::string &templ, unsigned int current_extruder_id, const DynamicConfig *config_override = nullptr); | ||||
|     bool            enable_cooling_markers() const { return m_enable_cooling_markers; } | ||||
|     std::string     extrusion_role_to_string_for_parser(const ExtrusionRole &); | ||||
| 
 | ||||
|     // For Perl bindings, to be used exclusively by unit tests.
 | ||||
|     unsigned int    layer_count() const { return m_layer_count; } | ||||
|  |  | |||
|  | @ -819,7 +819,7 @@ static std::vector<std::string> s_Preset_printer_options { | |||
|     "printer_technology", | ||||
|     "printable_area", "bed_exclude_area","bed_custom_texture", "bed_custom_model", "gcode_flavor", | ||||
|     "fan_kickstart", "fan_speedup_time", "fan_speedup_overhangs", | ||||
|     "single_extruder_multi_material", "manual_filament_change", "machine_start_gcode", "machine_end_gcode", "before_layer_change_gcode", "layer_change_gcode", "time_lapse_gcode", "change_filament_gcode", | ||||
|     "single_extruder_multi_material", "manual_filament_change", "machine_start_gcode", "machine_end_gcode", "before_layer_change_gcode", "layer_change_gcode", "time_lapse_gcode", "change_filament_gcode", "change_extrusion_role_gcode", | ||||
|     "printer_model", "printer_variant", "printable_height", "extruder_clearance_radius", "extruder_clearance_height_to_lid", "extruder_clearance_height_to_rod", | ||||
|     "default_print_profile", "inherits", | ||||
|     "silent_mode", | ||||
|  |  | |||
|  | @ -3970,6 +3970,15 @@ def = this->add("filament_loading_speed", coFloats); | |||
|     def->mode = comAdvanced; | ||||
|     def->set_default_value(new ConfigOptionString("")); | ||||
| 
 | ||||
|     def = this->add("change_extrusion_role_gcode", coString); | ||||
|     def->label = L("Change extrusion role G-code"); | ||||
|     def->tooltip = L("This gcode is inserted when the extrusion role is changed"); | ||||
|     def->multiline = true; | ||||
|     def->full_width = true; | ||||
|     def->height = 5; | ||||
|     def->mode = comAdvanced; | ||||
|     def->set_default_value(new ConfigOptionString("")); | ||||
| 
 | ||||
|     def = this->add("top_surface_line_width", coFloatOrPercent); | ||||
|     def->label = L("Top surface"); | ||||
|     def->category = L("Quality"); | ||||
|  |  | |||
|  | @ -969,6 +969,7 @@ PRINT_CONFIG_CLASS_DEFINE( | |||
|     ((ConfigOptionBool,                single_extruder_multi_material_priming)) | ||||
|     ((ConfigOptionBool,                wipe_tower_no_sparse_layers)) | ||||
|     ((ConfigOptionString,              change_filament_gcode)) | ||||
|     ((ConfigOptionString,              change_extrusion_role_gcode)) | ||||
|     ((ConfigOptionFloat,               travel_speed)) | ||||
|     ((ConfigOptionFloat,               travel_speed_z)) | ||||
|     ((ConfigOptionBool,                silent_mode)) | ||||
|  |  | |||
|  | @ -3231,6 +3231,17 @@ void TabPrinter::build_fff() | |||
|         option.opt.height = gcode_field_height;//150;
 | ||||
|         optgroup->append_single_option_line(option); | ||||
| 
 | ||||
|         optgroup = page->new_optgroup(L("Change extrusion role G-code"), L"param_gcode", 0); | ||||
|         optgroup->m_on_change = [this, optgroup](const t_config_option_key& opt_key, const boost::any& value) { | ||||
|             validate_custom_gcode_cb(this, optgroup, opt_key, value); | ||||
|         }; | ||||
| 
 | ||||
|         option = optgroup->get_option("change_extrusion_role_gcode"); | ||||
|         option.opt.full_width = true; | ||||
|         option.opt.is_code = true; | ||||
|         option.opt.height = gcode_field_height;//150;
 | ||||
|         optgroup->append_single_option_line(option); | ||||
| 
 | ||||
|         optgroup = page->new_optgroup(L("Pause G-code"), L"param_gcode", 0); | ||||
|         optgroup->m_on_change = [this, optgroup](const t_config_option_key& opt_key, const boost::any& value) { | ||||
|             validate_custom_gcode_cb(this, optgroup, opt_key, value); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Ocraftyone
						Ocraftyone