• Tags
  • Documentation
  • Order
  • Register
  • Login
Duet3D Logo Duet3D
  • Tags
  • Documentation
  • Order
  • Register
  • Login

Cura Script to Automatically Probe Only Printed Area

Scheduled Pinned Locked Moved
General Discussion
15
60
7.3k
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • undefined
    zapta @DK90
    last edited by 1 Jun 2020, 05:46

    @DK90, if you use panel due and prusaslicer (and maybe cura, didn't try), try to enable Support Remaining Time in the Printer Settings | General, tab. This will include M73 time markers in the gcode that which cause the post processing script to show remaining hours and minutes in the Standby fields of Panel Duet (ignore the '-' prefix).

    This time estimation is much more consistent than the ones provided by Duet.

    undefined 1 Reply Last reply 1 Jun 2020, 05:52 Reply Quote 1
    • undefined
      DK90 @zapta
      last edited by 1 Jun 2020, 05:52

      @zapta Thank you for the info. I will try it. That sound good.

      1 Reply Last reply Reply Quote 0
      • undefined
        tcj
        last edited by tcj 13 Jun 2020, 17:49

        @zapta I'm sorry to say that, but it does not work properly yet.
        The script gives

        M557 X-10:32 Y-10:32 P3:3
        

        where it should deliver

        M557 X-32:32 Y-32:32 P3:3
        

        for a testcube in the middle of the bed with some mm of skirt

        total dimensions +/- 21.xx mm

        undefined undefined 2 Replies Last reply 13 Jun 2020, 23:10 Reply Quote 0
        • undefined
          OwenD @tcj
          last edited by 13 Jun 2020, 23:10

          @tcj what are your probe offsets?

          1 Reply Last reply Reply Quote 0
          • undefined
            CCS86
            last edited by 13 Jun 2020, 23:35

            Probe offsets wouldn't matter.

            Posting the gcode would be helpful though.

            1 Reply Last reply Reply Quote 0
            • undefined
              zapta @tcj
              last edited by 14 Jun 2020, 01:26

              @tcj, try to run the script manually and see what it prints. To do that, run it from command line with the same arguments you have in the slicer and also add the name of the gcode file at the end of the command line.

              When I run it I get prints like this

              MESHABLE area: 30.0:280.0,30.0:280.0
              Opening gcode file: /var/folders/dt/1t1sf6d574d3l023pknh_754000cbj/T/.PrusaSlicer.upload.7e0e-12b6-1a76-0282
              Read 83648 lines
              Parsing state = ParsingState.WAITING_FOR_LAYER1
              ;Automesh: begin layer 0
              Parsing state = ParsingState.IN_LAYER1
              ;Automesh: begin layer 1
              Parsing state = ParsingState.LAYER1_DONE
              First layer print areas: 92:189,131:210
              printArea: 92:189,131:210
              Will use 4 x 3 mesh points
              Marker: M557 TBD  ; marker for automesh script
              Inserted: M557 X82:199 Y121:220 P4:3
              

              (if you prefer, post your gcode file and command line parameters and I can test it here)

              1 Reply Last reply Reply Quote 0
              • undefined
                tcj
                last edited by 14 Jun 2020, 11:11

                C:\Users\tcj-a>C:\Users\tcj-a\AppData\Local\Programs\Python\Python38-32\python.exe C:\Users\tcj-a\Documents\scripts\duet3d_automesh.py C:\Users\tcj-a\Desktop\single_wall_box.gcode --meshable=-185:185,-185:185
                MESHABLE area: -185.0:185.0,-185.0:185.0
                Opening gcode file: C:\Users\tcj-a\Desktop\single_wall_box.gcode
                Read 7472 lines
                Parsing state = ParsingState.WAITING_FOR_LAYER1
                ; Automesh: begin layer 0
                Parsing state = ParsingState.IN_LAYER1
                ; Automesh: begin layer 1
                Parsing state = ParsingState.LAYER1_DONE
                First layer print areas: 0:22,12:22
                printArea: 0:22,12:22
                Will use 3 x 3 mesh points
                Marker: M557 TBD  ; parameters will be set automatically
                Inserted: M557 X-10:32 Y2:32 P3:3
                

                single_wall_box.gcode

                obviously the script does not handle negative numbers as needed, because the first layer print area is -22:-22, 22:22

                undefined 1 Reply Last reply 14 Jun 2020, 14:17 Reply Quote 0
                • undefined
                  zapta @tcj
                  last edited by zapta 14 Jun 2020, 14:17

                  @tcj, thanks for the example and for your patient.

                  I made a fix and am now getting the output below. The problem existed in the original code posted in this thread, parsing only non negative x and y values.

                  MESHABLE area: -100.0:100.0,-100.0:100.0
                  Opening gcode file: single_wall_box.gcode
                  Read 7472 lines
                  Parsing state = ParsingState.WAITING_FOR_LAYER1
                  ; Automesh: begin layer 0
                  Parsing state = ParsingState.IN_LAYER1
                  ; Automesh: begin layer 1
                  Parsing state = ParsingState.LAYER1_DONE
                  First layer print areas: -22:22,-22:22
                  printArea: -22:22,-22:22
                  Will use 3 x 3 mesh points
                  Marker: M557 TBD  ; parameters will be set automatically
                  Inserted: M557 X-32:32 Y-32:32 P3:3
                  

                  https://github.com/zapta/misc/blob/master/duet3d_automesh/duet3d_automesh.iml

                  undefined 1 Reply Last reply 15 Jun 2020, 00:08 Reply Quote 1
                  • undefined
                    tcj
                    last edited by 14 Jun 2020, 14:21

                    @zapta thank you

                    1 Reply Last reply Reply Quote 1
                    • undefined
                      Baenwort @zapta
                      last edited by 15 Jun 2020, 00:08

                      @zapta said in Cura Script to Automatically Probe Only Printed Area:

                      @tcj, thanks for the example and for your patient.

                      I made a fix and am now getting the output below. The problem existed in the original code posted in this thread, parsing only non negative x and y values.

                      https://github.com/zapta/misc/blob/master/duet3d_automesh/duet3d_automesh.iml

                      Does this bring it closer to working for Delta's? Or at least probing a square area of the circular bed?

                      undefined undefined 2 Replies Last reply 15 Jun 2020, 01:37 Reply Quote 0
                      • undefined
                        zapta @Baenwort
                        last edited by zapta 15 Jun 2020, 01:37

                        @Baenwort, what are the special requirements for delta compared to a cartesian?

                        The current script finds the bounding rectangle of the first layer's print (negative numbers are ok) and generates a M557 command with X and Y ranges and number of probe points.

                        In case of a delta, the bounding rectangle can have points outside the round print area but I presume the duet will ignore them.

                        Edit: for delta, if objects are placed in the center, it's possible to compute the radius from (0, 0) and issue a M557 with a R param.

                        1 Reply Last reply Reply Quote 0
                        • undefined
                          Red Sand Robot
                          last edited by 16 Jun 2020, 01:13

                          I'm also having an issue when getting the post processing script to run. I am getting this:

                          Post-processing script C:\Users\Jack\AppData\Local\Programs\Python\Python38-32\python.exe "C:\Program Files\PrusaSlicer-2.2.0+win64-202003211145\PrusaSlicer-2.2.0+win64-202003211145\duet3d_automesh.py" on file C:\Users\Jack\Documents\3D Printing\Stuff\Flex Tube Support.gcode failed.
                          Error code: 1
                          

                          Any ideas on what I may be doing wrong?
                          This is my full start gcode script:

                          M82 ;absolute extrusion mode
                          G21 ;metric values
                          G90 ;absolute positioning
                          M82 ; set extruder to absolute mode
                          M107 ;start with the fan off
                          G29 S2; clears existing bed heightmap
                          
                          ; For automesh
                          M557 TBD  ; parameters will be set automatically
                          G28; home all
                          
                          G32; motorized gantry plane correction
                          G32;
                          G32; Repeated 3 times to ensure its correct
                          
                          G29  Mesh Bed compensation 
                          
                          G1 Z20 F6000 ;move the platform down 15mm
                          G1 F100 E9 ;extrude 9mm of feed stock
                          G92 E0 ;zero the extruded length
                          
                          

                          almost an engineer

                          undefined undefined 2 Replies Last reply 16 Jun 2020, 02:01 Reply Quote 0
                          • undefined
                            OwenD @Red Sand Robot
                            last edited by 16 Jun 2020, 02:01

                            @Red-Sand-Robot
                            Double check the content of the script.
                            I just tried yesterday and was getting the same error.
                            The first time I downloaded, I right clicked the link and selected "download link" or some such.
                            Problem was it downloaded the whole HTML page, not just the python script. (DOH!)
                            After copying and pasting just the script content it worked fine.

                            1 Reply Last reply Reply Quote 0
                            • undefined
                              zapta @Red Sand Robot
                              last edited by 16 Jun 2020, 03:04

                              @Red-Sand-Robot, I would suggest to first run it manually from the command line. It will give you more information on what's going on. (after verifying that the script download is ok per OwenD's suggestion)

                              undefined 1 Reply Last reply 16 Jun 2020, 04:30 Reply Quote 0
                              • undefined
                                Red Sand Robot @zapta
                                last edited by 16 Jun 2020, 04:30

                                @zapta Command line? As in my computer or PrusaSlicer? Sorry, the programming side of things isn't my forte.

                                almost an engineer

                                undefined 1 Reply Last reply 16 Jun 2020, 05:14 Reply Quote 0
                                • undefined
                                  zapta @Red Sand Robot
                                  last edited by 16 Jun 2020, 05:14

                                  @Red-Sand-Robot, it seems that you work on windows. I meant commands types in the DOS window. I don't have here a Windows computer but others here may be able to explain it better.

                                  https://www.lifewire.com/how-to-open-command-prompt-2618089

                                  undefined 1 Reply Last reply 16 Jun 2020, 18:14 Reply Quote 0
                                  • undefined
                                    Red Sand Robot @zapta
                                    last edited by 16 Jun 2020, 18:14

                                    @zapta Yes, I work on windows. Haven't made the jump to attempt to learn Linux or associated stuff yet though I suppose I should if I ever want to use a RPI for anything useful.

                                    When I ran the script from the command prompt window, I received this output:

                                    C:\Users\Jack>AppData\Local\Programs\Python\Python38-32\python.exe "C:\Users\Jack\Documents\3D Printing\PrusaSlicerScript\duet3d_automesh.py"
                                    usage: duet3d_automesh.py [-h] [--meshable MESHABLE] [--margin MARGIN] [--spacing SPACING]
                                                              [--min_points {2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49}]
                                                              [--max_points {2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49}]
                                                              [--first_layer_start FIRST_LAYER_START] [--first_layer_end FIRST_LAYER_END]
                                                              file_path
                                    duet3d_automesh.py: error: the following arguments are required: file_path
                                    

                                    Does that look like it is functioning correctly? I'm guessing that the file_path argument is talking about the .gcode file, but if not that would indicate an error with how I'm calling the script from what I understand.

                                    almost an engineer

                                    1 Reply Last reply Reply Quote 0
                                    • undefined
                                      Red Sand Robot
                                      last edited by 16 Jun 2020, 18:45

                                      @zapta Figured out that my main issue was that I never changed the meshable area parameters to match my machine. I guess I just assumed when it says "default" that the script would also parse that stuff from the slicer, but in hindsight the script doesn't function that way, it only looks at the .gcode file after it has been output by the slicer.

                                      Leaving output up as an example of what it looks like the user does not properly define the meshable area in regards to their machine. My machine has -100:100,-100:100 for a meshable area.

                                      C:\Users\Jack>C:\Users\Jack\AppData\Local\Programs\Python\Python38-32\python.exe C:\Users\Jack\Documents\3D-Printing\PrusaSlicerScript\duet3d_automesh.py C:\Users\Jack\Documents\3D-Printing\Stuff\flex_tube_support2.gcode
                                      MESHABLE area: 30.0:280.0,30.0:280.0
                                      Opening gcode file: C:\Users\Jack\Documents\3D-Printing\Stuff\flex_tube_support2.gcode
                                      Read 33095 lines
                                      Parsing state = ParsingState.WAITING_FOR_LAYER1
                                      ; Automesh: begin layer 0
                                      Parsing state = ParsingState.IN_LAYER1
                                      ; Automesh: begin layer 1
                                      Parsing state = ParsingState.LAYER1_DONE
                                      First layer print areas: -13:13,-48:48
                                      printArea: -13:13,-48:48
                                      Traceback (most recent call last):
                                        File "C:\Users\Jack\Documents\3D-Printing\PrusaSlicerScript\duet3d_automesh.py", line 371, in <module>
                                          main()
                                        File "C:\Users\Jack\Documents\3D-Printing\PrusaSlicerScript\duet3d_automesh.py", line 218, in main
                                          mesh_area.clip_to(MESHABLE_AREA)
                                        File "C:\Users\Jack\Documents\3D-Printing\PrusaSlicerScript\duet3d_automesh.py", line 165, in clip_to
                                          self.x_span.clip_to(other_rect.x_span)
                                        File "C:\Users\Jack\Documents\3D-Printing\PrusaSlicerScript\duet3d_automesh.py", line 126, in clip_to
                                          self.__check()
                                        File "C:\Users\Jack\Documents\3D-Printing\PrusaSlicerScript\duet3d_automesh.py", line 105, in __check
                                          fatal_error(f'Invalid range value: {self}')
                                        File "C:\Users\Jack\Documents\3D-Printing\PrusaSlicerScript\duet3d_automesh.py", line 83, in fatal_error
                                          raise Exception('Fatal error: ' + message)
                                      Exception: Fatal error: Invalid range value: 30.0:23
                                      

                                      almost an engineer

                                      undefined 1 Reply Last reply 16 Jun 2020, 19:59 Reply Quote 0
                                      • undefined
                                        zapta @Red Sand Robot
                                        last edited by zapta 16 Jun 2020, 19:59

                                        @Red-Sand-Robot, I think we are almost there 😉

                                        Can you post here your file flex_tube_support2.gcode ? I will try to run it myself and check that error.

                                        Edit: to set your own meshable area, add to the command line the following flag:

                                        --meshable=-100:100,-100:100

                                        undefined 1 Reply Last reply 16 Jun 2020, 20:17 Reply Quote 0
                                        • undefined
                                          Red Sand Robot @zapta
                                          last edited by 16 Jun 2020, 20:17

                                          @zapta Would --meshable=-100:100,-100:100 go after the output path specification in PrusaSlicer? I just manually changed the default in the script.

                                          parser.add_argument('--meshable',
                                                              default="-100:100,-100:100",
                                                              help='Bed meshable area x1:x2,y1:y2')
                                          

                                          Here is the .gcode file. I have my 0,0 point in the center of the build plate. I know that you previously added support for negative positional values so I don't think that would be the issue
                                          flex_tube_support2.gcode

                                          almost an engineer

                                          undefined 1 Reply Last reply 17 Jun 2020, 04:27 Reply Quote 0
                                          • First post
                                            Last post
                                          Unless otherwise noted, all forum content is licensed under CC-BY-SA