mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-11-02 20:51:23 -07:00 
			
		
		
		
	ENH: object_skip: use identify_id for cli when skipping object
Change-Id: Ibbe3262b4817f82b7ac824ba6d4b3efd7f0ed886
This commit is contained in:
		
							parent
							
								
									e50513ff75
								
							
						
					
					
						commit
						ef06dfc931
					
				
					 5 changed files with 21 additions and 14 deletions
				
			
		| 
						 | 
				
			
			@ -2217,7 +2217,7 @@ int CLI::run(int argc, char **argv)
 | 
			
		|||
                                        part_plate->set_tmp_gcode_path(outfile);
 | 
			
		||||
                                    }
 | 
			
		||||
                                    BOOST_LOG_TRIVIAL(info) << "process finished, will export gcode temporily to " << outfile << std::endl;
 | 
			
		||||
                                    outfile = (dynamic_cast<Print*>(print))->export_gcode(outfile, gcode_result, nullptr);
 | 
			
		||||
                                    outfile = (dynamic_cast<Print*>(print))->export_gcode(outfile, gcode_result, nullptr, true);
 | 
			
		||||
                                    //outfile_final = (dynamic_cast<Print*>(print))->print_statistics().finalize_output_path(outfile);
 | 
			
		||||
                                    //m_fff_print->export_gcode(m_temp_output_path, m_gcode_result, [this](const ThumbnailsParams& params) { return this->render_thumbnails(params); });
 | 
			
		||||
                                }/* else {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -890,7 +890,7 @@ std::vector<std::pair<coordf_t, std::vector<GCode::LayerToPrint>>> GCode::collec
 | 
			
		|||
            ordering.emplace_back(ordering_item);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    if (!errors.empty()) { throw Slic3r::SlicingErrors(errors); }
 | 
			
		||||
 | 
			
		||||
    std::sort(ordering.begin(), ordering.end(), [](const OrderingItem& oi1, const OrderingItem& oi2) { return oi1.print_z < oi2.print_z; });
 | 
			
		||||
| 
						 | 
				
			
			@ -1048,7 +1048,7 @@ bool GCode::is_BBL_Printer()
 | 
			
		|||
    return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void GCode::do_export(Print* print, const char* path, GCodeProcessorResult* result, ThumbnailsGeneratorCallback thumbnail_cb)
 | 
			
		||||
void GCode::do_export(Print* print, const char* path, GCodeProcessorResult* result, ThumbnailsGeneratorCallback thumbnail_cb, bool using_identify_id)
 | 
			
		||||
{
 | 
			
		||||
    PROFILE_CLEAR();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1108,7 +1108,7 @@ void GCode::do_export(Print* print, const char* path, GCodeProcessorResult* resu
 | 
			
		|||
 | 
			
		||||
    try {
 | 
			
		||||
        m_placeholder_parser_failed_templates.clear();
 | 
			
		||||
        this->_do_export(*print, file, thumbnail_cb);
 | 
			
		||||
        this->_do_export(*print, file, thumbnail_cb, using_identify_id);
 | 
			
		||||
        file.flush();
 | 
			
		||||
        if (file.is_error()) {
 | 
			
		||||
            file.close();
 | 
			
		||||
| 
						 | 
				
			
			@ -1437,7 +1437,7 @@ static BambuBedType to_bambu_bed_type(BedType type)
 | 
			
		|||
    return bambu_bed_type;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGeneratorCallback thumbnail_cb)
 | 
			
		||||
void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGeneratorCallback thumbnail_cb, bool using_identify_id)
 | 
			
		||||
{
 | 
			
		||||
    PROFILE_FUNC();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1530,7 +1530,14 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
 | 
			
		|||
        m_label_objects_ids.reserve(print.num_object_instances());
 | 
			
		||||
        for (const PrintObject* print_object : print.objects())
 | 
			
		||||
            for (const PrintInstance& print_instance : print_object->instances())
 | 
			
		||||
                m_label_objects_ids.push_back(print_instance.model_instance->id().id);
 | 
			
		||||
            {
 | 
			
		||||
                size_t instance_identify_id;
 | 
			
		||||
                if (using_identify_id && print_instance.model_instance->loaded_id > 0)
 | 
			
		||||
                    instance_identify_id = print_instance.model_instance->loaded_id;
 | 
			
		||||
                else
 | 
			
		||||
                    instance_identify_id = print_instance.model_instance->id().id;
 | 
			
		||||
                m_label_objects_ids.push_back(instance_identify_id);
 | 
			
		||||
            }
 | 
			
		||||
        std::sort(m_label_objects_ids.begin(), m_label_objects_ids.end());
 | 
			
		||||
 | 
			
		||||
        std::string objects_id_list = "; model label id: ";
 | 
			
		||||
| 
						 | 
				
			
			@ -4257,7 +4264,7 @@ bool GCode::needs_retraction(const Polyline &travel, ExtrusionRole role, LiftTyp
 | 
			
		|||
 | 
			
		||||
        for (size_t i = 0; i < idx_of_object_sorted.size();i++) {
 | 
			
		||||
            size_t idx = idx_of_object_sorted[i];
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
            BoundingBox obj_bbox    = boundingBox_for_objects[idx];
 | 
			
		||||
            BoundingBox travel_bbox = get_extents(travel);
 | 
			
		||||
            obj_bbox.offset(scale_(EPSILON));
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -167,7 +167,7 @@ public:
 | 
			
		|||
 | 
			
		||||
    // throws std::runtime_exception on error,
 | 
			
		||||
    // throws CanceledException through print->throw_if_canceled().
 | 
			
		||||
    void            do_export(Print* print, const char* path, GCodeProcessorResult* result = nullptr, ThumbnailsGeneratorCallback thumbnail_cb = nullptr);
 | 
			
		||||
    void            do_export(Print* print, const char* path, GCodeProcessorResult* result = nullptr, ThumbnailsGeneratorCallback thumbnail_cb = nullptr, bool using_identify_id = false);
 | 
			
		||||
 | 
			
		||||
    //BBS: set offset for gcode writer
 | 
			
		||||
    void set_gcode_offset(double x, double y) { m_writer.set_xy_offset(x, y); m_processor.set_xy_offset(x, y);}
 | 
			
		||||
| 
						 | 
				
			
			@ -277,7 +277,7 @@ private:
 | 
			
		|||
        FILE *f = nullptr;
 | 
			
		||||
        GCodeProcessor &m_processor;
 | 
			
		||||
    };
 | 
			
		||||
    void            _do_export(Print &print, GCodeOutputStream &file, ThumbnailsGeneratorCallback thumbnail_cb);
 | 
			
		||||
    void            _do_export(Print &print, GCodeOutputStream &file, ThumbnailsGeneratorCallback thumbnail_cb, bool using_identify_id = false);
 | 
			
		||||
 | 
			
		||||
    static std::vector<LayerToPrint>        		                   collect_layers_to_print(const PrintObject &object);
 | 
			
		||||
    static std::vector<std::pair<coordf_t, std::vector<LayerToPrint>>> collect_layers_to_print(const Print &print);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1754,7 +1754,7 @@ void Print::process(bool use_cache)
 | 
			
		|||
// The export_gcode may die for various reasons (fails to process filename_format,
 | 
			
		||||
// write error into the G-code, cannot execute post-processing scripts).
 | 
			
		||||
// It is up to the caller to show an error message.
 | 
			
		||||
std::string Print::export_gcode(const std::string& path_template, GCodeProcessorResult* result, ThumbnailsGeneratorCallback thumbnail_cb)
 | 
			
		||||
std::string Print::export_gcode(const std::string& path_template, GCodeProcessorResult* result, ThumbnailsGeneratorCallback thumbnail_cb, bool using_identify_id)
 | 
			
		||||
{
 | 
			
		||||
    // output everything to a G-code file
 | 
			
		||||
    // The following call may die if the filename_format template substitution fails.
 | 
			
		||||
| 
						 | 
				
			
			@ -1774,7 +1774,7 @@ std::string Print::export_gcode(const std::string& path_template, GCodeProcessor
 | 
			
		|||
    //BBS: compute plate offset for gcode-generator
 | 
			
		||||
    const Vec3d origin = this->get_plate_origin();
 | 
			
		||||
    gcode.set_gcode_offset(origin(0), origin(1));
 | 
			
		||||
    gcode.do_export(this, path.c_str(), result, thumbnail_cb);
 | 
			
		||||
    gcode.do_export(this, path.c_str(), result, thumbnail_cb, using_identify_id);
 | 
			
		||||
    //BBS
 | 
			
		||||
    result->conflict_result = m_conflict_result;
 | 
			
		||||
    return path.c_str();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -198,7 +198,7 @@ struct PrintInstance
 | 
			
		|||
    BoundingBoxf3   get_bounding_box();
 | 
			
		||||
    Polygon get_convex_hull_2d();
 | 
			
		||||
    // OrcaSlicer
 | 
			
		||||
    // 
 | 
			
		||||
    //
 | 
			
		||||
    // instance id
 | 
			
		||||
    size_t               id;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -521,7 +521,7 @@ private:
 | 
			
		|||
    PrintObject*                            m_shared_object{ nullptr };
 | 
			
		||||
 | 
			
		||||
    // OrcaSlicer
 | 
			
		||||
    // 
 | 
			
		||||
    //
 | 
			
		||||
    // object id for klipper firmware only
 | 
			
		||||
    size_t               m_klipper_object_id;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -699,7 +699,7 @@ public:
 | 
			
		|||
    void                process(bool use_cache = false) override;
 | 
			
		||||
    // Exports G-code into a file name based on the path_template, returns the file path of the generated G-code file.
 | 
			
		||||
    // If preview_data is not null, the preview_data is filled in for the G-code visualization (not used by the command line Slic3r).
 | 
			
		||||
    std::string         export_gcode(const std::string& path_template, GCodeProcessorResult* result, ThumbnailsGeneratorCallback thumbnail_cb = nullptr);
 | 
			
		||||
    std::string         export_gcode(const std::string& path_template, GCodeProcessorResult* result, ThumbnailsGeneratorCallback thumbnail_cb = nullptr, bool using_identify_id = false);
 | 
			
		||||
    //return 0 means successful
 | 
			
		||||
    int                 export_cached_data(const std::string& dir_path, bool with_space=false);
 | 
			
		||||
    int                 load_cached_data(const std::string& directory);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue