Navigation

    Duet3D Logo

    Duet3D

    • Register
    • Login
    • Search
    • Categories
    • Tags
    • Documentation
    • Order

    Cura strips indents from conditional G code

    General Discussion
    5
    9
    86
    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.
    • OwenD
      OwenD last edited by OwenD

      Just a heads up for anyone playing with conditional g code.
      Cura strips leading spaces and tab indents from the start & end G code when you close the program.
      So it’ll work fine when you test it, but next time you open Cura all the indents will be gone, so all commands will be executed.
      e.g the example of

      if !move.axes[0].homed || !move.axes[1].homed || !move.axes[2].homed
             G28
      // rest of start code
      

      will become after restarting Cura

      if !move.axes[0].homed || !move.axes[1].homed || !move.axes[2].homed
      G28
      

      Causing G28 to be called regardless of how the IF statement evaluates.

      Veti zapta OwenD 3 Replies Last reply Reply Quote 0
      • Veti
        Veti @OwenD last edited by

        move the code to a macro and call the macro

        1 Reply Last reply Reply Quote 0
        • Phaedrux
          Phaedrux Moderator last edited by

          This is a good case for using the start.g macro which runs when a print is started before any of the sliced gcode file is executed.

          1 Reply Last reply Reply Quote 0
          • zapta
            zapta @OwenD last edited by

            @OwenD, this justified a bug report or feature request (e.g. hard space) from Cura. Saving operation modifying the settings is bad.

            OwenD 1 Reply Last reply Reply Quote 0
            • OwenD
              OwenD @OwenD last edited by

              @OwenD

              Oops. Forgot HTML would strip the spaces as well.
              It was late. LOL

              Yes you can easily use a macro.
              Just remember that if the slicers doesn’t see some settings in the start code, it will automatically add them, so you may still not get the results you planned.

              It’s going to take a while for the slicers you align with the new features.
              As I said, just a heads up.

              A Former User 1 Reply Last reply Reply Quote 0
              • A Former User
                A Former User @OwenD last edited by

                @OwenD said in Cura strips indents from conditional G code:

                Oops. Forgot HTML would strip the spaces as well.

                put ``` on a line over and below the code to keep the formatting here

                   like so
                

                cde2e5a2-8a34-4a99-be26-b628d11f0e0f-image.png

                OwenD 1 Reply Last reply Reply Quote 0
                • OwenD
                  OwenD @Guest last edited by

                  @bearer 👍

                  1 Reply Last reply Reply Quote 0
                  • OwenD
                    OwenD @zapta last edited by

                    @zapta Has been submitted
                    https://github.com/Ultimaker/Cura/issues/7056

                    owendare created this issue in Ultimaker/Cura

                    open Support for conditional G Code in start & end GCode #7056

                    zapta 1 Reply Last reply Reply Quote 0
                    • zapta
                      zapta @OwenD last edited by

                      @OwenD, very good. Thanks.

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post
                      Unless otherwise noted, all forum content is licensed under CC-BY-SA