sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    How to reset an incremental value used in an if statement?

    Scheduled Pinned Locked Moved Developers' Forum
    7 Posts 4 Posters 921 Views 4 Watching
    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.
    • T Offline
      tomot
      last edited by

      I hope this attachment illustrates the issue:
      after the routine has run I want to reset @fix back to its original value of @fix = 60
      in order to run another if statement of a similar nature on another face.


      fix.png

      [my plugins](http://thingsvirtual.blogspot.ca/)
      tomot

      1 Reply Last reply Reply Quote 0
      • TIGT Offline
        TIG Moderator
        last edited by

        Why didn't you post the code snippet inside a 'code' block?
        It means we have to retype everything !!
        Anyway... after you have the
        @fix += @jmp1
        add something like this after the ' while...end'
        ` if @fix >= 432
        @fix = 60

        do other stuff ???

        end`
        or whatever you like...... πŸ˜•
        Only posting a selection is somewhat useless... πŸ˜•

        TIG

        1 Reply Last reply Reply Quote 0
        • Dan RathbunD Offline
          Dan Rathbun
          last edited by

          #default intermediate column placement
          @fix = @flenx/2-@fcol if not @fix
          startfix = @fix
          
          if ...
            # @fix gets changed here
          end
          
          @fix = startfix
          
          # a new if statement here
          
          

          I'm not here much anymore.

          1 Reply Last reply Reply Quote 0
          • T Offline
            tomot
            last edited by

            thanks 2 both if u

            if @fix >=@flenx/2-@fcol
               @fix = @flenx/2-@fcol
            end
            

            fixed the issue πŸ˜„

            [my plugins](http://thingsvirtual.blogspot.ca/)
            tomot

            1 Reply Last reply Reply Quote 0
            • thomthomT Offline
              thomthom
              last edited by

              @tomot said:

              thanks 2 both if u

              if @fix >=@flenx/2-@fcol
              >    @fix = @flenx/2-@fcol
              > end
              

              fixed the issue πŸ˜„

              ?

              So what you really asked for was how to ensure a maximum value?

              Thomas Thomassen β€” SketchUp Monkey & Coding addict
              List of my plugins and link to the CookieWare fund

              1 Reply Last reply Reply Quote 0
              • T Offline
                tomot
                last edited by

                @thomthom said:

                @tomot said:

                thanks 2 both if u

                if @fix >=@flenx/2-@fcol
                > >    @fix = @flenx/2-@fcol
                > > end
                

                fixed the issue πŸ˜„

                ?

                So what you really asked for was how to ensure a maximum value?

                NO! ...the original value @fix = 60 just happened to be the result of 2 user selected variables, @flenx & @fcol. When the "while..end" loop finished the value of @fix = 432 I now needed to reset @fix back to its original user selected value.
                I had been looking in the API, thinking there might be a 'reset' comment 😳

                [my plugins](http://thingsvirtual.blogspot.ca/)
                tomot

                1 Reply Last reply Reply Quote 0
                • Dan RathbunD Offline
                  Dan Rathbun
                  last edited by

                  My solution is more readable. Let me rewrite it, thus:

                  #default intermediate column placement
                  resetfix =( @fix ? @fix ; @flenx/2-@fcol )
                   
                  if ...
                    # @fix gets changed here
                  end
                   
                  @fix = resetfix
                   
                  # a new if statement;
                  if ...
                    # @fix gets changed again ...
                  end
                  
                  @fix = resetfix
                  
                  # ANOTHER if statement that may change @fix;
                  

                  I'm not here much anymore.

                  1 Reply Last reply Reply Quote 0
                  • 1 / 1
                  • First post
                    Last post
                  Buy SketchPlus
                  Buy SUbD
                  Buy WrapR
                  Buy eBook
                  Buy Modelur
                  Buy Vertex Tools
                  Buy SketchCuisine
                  Buy FormFonts

                  Advertisement