Skip to content

Problem when using prusa slicer and standalone script #46

@jonschke

Description

@jonschke

If I try to join the two appended gcodes I get this error

Converting additive gcode to relative positioning...
Traceback (most recent call last):
  File "main.py", line 26, in <module>
    asmbl_parser = Parser(args.config)
  File "C:\Users\Jonat\Desktop\ASMBL-master\src\ASMBL_parser.py", line 34, in __init__
    self.main()
  File "C:\Users\Jonat\Desktop\ASMBL-master\src\ASMBL_parser.py", line 51, in main
    self.gcode_add = utils.convert_relative(self.gcode_add)
  File "C:\Users\Jonat\Desktop\ASMBL-master\src\utils.py", line 46, in convert_relative
    extrusion_diff = float(current_extrusion) - float(last_e[last_tool])
ValueError: could not convert string to float: '-1.50000 F1800.000'

The problem seems to be that the sequence of the gcode from the prusa slicer (G1 E0.5 F1800.00) is different to the sequence generated by the fusion slicer (G1 F1800 E0.5)
I already looked into the function convert_relative in utils.py and altered the absolute section to get the current extrusion:

if absolute_mode:
            if line_start == 'G0' or line_start == 'G1':
                try:
                    line_split = line.split(' ')
                    current_extrusion = 0
                    for section in range(0, len(line_split)):
                        if (line_split[section].find("E") == 0):
                            current_extrusion = line_split[section].split("E")[1]
                            break
                    extrusion_diff = float(current_extrusion) - float(last_e[last_tool])
                    extrusion_diff = round(extrusion_diff, 3)
                    last_e[last_tool] = current_extrusion
                    line_split[section] = "E" + str(extrusion_diff)
                    line = " ".join(line_split)
                except IndexError:
                    pass
        gcode_rel += line + '\n'

But then I this error comes next:

parsing files...
Opening files...
Converting additive gcode to relative positioning...
Spliting additive gcode layers...
Traceback (most recent call last):
  File "main.py", line 26, in <module>
    asmbl_parser = Parser(args.config)
  File "C:\Users\Jonat\Documents\Persoehnliche Dokumente\Engineering\ToolChanger\ASMBL-master\src\ASMBL_parser.py", line 34, in __init__
    self.main()
  File "C:\Users\Jonat\Documents\Persoehnliche Dokumente\Engineering\ToolChanger\ASMBL-master\src\ASMBL_parser.py", line 57, in main
    self.gcode_add_layers = self.split_additive_layers(self.gcode_add)
  File "C:\Users\Jonat\Documents\Persoehnliche Dokumente\Engineering\ToolChanger\ASMBL-master\src\ASMBL_parser.py", line 115, in split_additive_layers
    gcode_add_layers.append(AdditiveGcodeLayer(layer, name))
  File "C:\Users\Jonat\Documents\Persoehnliche Dokumente\Engineering\ToolChanger\ASMBL-master\src\additive_gcode.py", line 18, in __init__
    self.layer_height = self.get_layer_height(self.gcode)
  File "C:\Users\Jonat\Documents\Persoehnliche Dokumente\Engineering\ToolChanger\ASMBL-master\src\additive_gcode.py", line 43, in get_layer_height
    height = min(line_heights)
ValueError: min() arg is an empty sequence

I think there is again an issue with the way the gcode is parsed

Wuerfel2matadd.zip

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingrefactorRefactor codereproducedbug was reproduced by dev

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions