Skip to content

Manage NONMESH entries in gcode #17

@Hikarinaka

Description

@Hikarinaka

Is your feature request related to a problem? Please describe

The preprocess cancellation utility have a problem with support structures in Cura. This is what is written in the description: "Cura sliced files have all support material as a single non-mesh entity. This means that when canceling an object, it's support will still print".

Describe the solution you'd like

I suggest removing the NONMESH tags from the code before running that utility.

This is the changes I suggest to make in KlipperPreprocessor.py script:
-add a new checkbox that enables deleting ";MESH:NONMESH" strings, effectievely including support structures into corresponding objects
-actually track the strings and remove that entries before calling the preprocess cancellation

add this to the settings in getSettingDataString def

                "add_nonmesh_entry_remove":
                {
                    "label": "Remove NONMESH entries",
                    "description": "This setting removes the NONMESH entries from gcode, such that Klipper doesn't treat supports as separate objects and supports are cancelled along the pbject.",
                    "type": "bool",
                    "default_value": false
                },

in the prepare script def:

    def prepare_temp_file(self, data: List[str], work_dir: str) -> Tuple[str, int]:
        Logger.log("d", "Initial run...")

        add_timelapse_take_frame: bool = self.getSettingValueByKey("add_timelapse_take_frame")
# new line that applies new checkbox
        add_nonmesh_entry_remove: bool = self.getSettingValueByKey("add_nonmesh_entry_remove")

        filename = os.path.join(work_dir, "work.gcode")
        total_layers = 0

        with open(filename, 'w') as work_file:
            for index, layer in enumerate(data):
                if index:
                    work_file.write(";CURA_DATA_SPLIT_HERE\n")

                lines = layer.split("\n")

                for line in lines:
                    if line.startswith(';LAYER:'):
                        total_layers += 1
                        if add_timelapse_take_frame:
                            work_file.write("TIMELAPSE_TAKE_FRAME\n")
#The nrat line is current code, just disabled 
#                   work_file.write(line + "\n")
#start NONMESH excluding
                    if add_nonmesh_entry_remove:
                        if not line.startswith(';MESH:NONMESH'):
                            work_file.write(line + "\n")
                    else:
                        work_file.write(line + "\n")
#End nonmesh exclusion injection

    

        Logger.log("d", "Total layers found: %d", total_layers)

        return filename, total_layers

Describe alternatives you've considered

No response

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions