sketchucation logo sketchucation
    • Login
    πŸ›£οΈ Road Profile Builder | Generate roads, curbs and pavements easily Download

    Plugin running indefinitely

    scheduled pinned locked moved Developers' Forum
    10 Posts 6 Posters 555 Views 6 Watching
    loading-more-posts
    • oldest-to-newest
    • newest-to-oldest
    • most-votes
    reply
    • reply-as-topic
    guest-login-reply
    deleted-message
    • T Offline
      The Nazgul uk
      last edited by

      Hi I've been using sketchup quite a lot but have just started
      writing plugins for it. I am trying to make a plugin which, once activated
      runs indefinitely and external inputs outside sketchup cause changes to what is being worked on. However, when I try an run the plugin in an while(1) loop sketchup crashes and stops working. Is there a way to make this work??

      Thanks for the help

      The Nazgul uk

      one-reply-to-this-post last-reply-time reply quote 0
      • B Offline
        Brett McAllister
        last edited by

        Does your while loop look like this?
        i = 0
        while i < 5
        puts i
        end
        i += 1

        one-reply-to-this-post last-reply-time reply quote 0
        • thomthomT Offline
          thomthom
          last edited by

          a while loop will most likely cause SU to stop updating the SU UI and stop responding.
          Maybe use UI.time?

          What does your loop do?

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

          one-reply-to-this-post last-reply-time reply quote 0
          • Chris FullmerC Offline
            Chris Fullmer
            last edited by

            What about something more like a web dialog - like the Prince IO game. The ruby is running, and the model is accepting input from outside of SketchUp and modifying the model based on that input. Is that what is needed?

            Lately you've been tan, suspicious for the winter.
            All my Plugins I've written

            one-reply-to-this-post last-reply-time reply quote 0
            • T Offline
              The Nazgul uk
              last edited by

              I first tried having a while loop of

              while(1)
              check text file procedure
              end

              this seemed to stop sketchup responding, so i tried a while loop with no output
              and this also crashed it. The prince IO game sounds like what I need

              one-reply-to-this-post last-reply-time reply quote 0
              • T Offline
                The Nazgul uk
                last edited by

                There is nothing in here I can see the way that it runs repeatedly can someone please help !!

                one-reply-to-this-post last-reply-time reply quote 0
                • J Offline
                  Jim
                  last edited by

                  What about using a timer?

                  Hi

                  one-reply-to-this-post last-reply-time reply quote 0
                  • thomthomT Offline
                    thomthom
                    last edited by

                    Related topic: http://forums.sketchucation.com/viewtopic.php?f=180&t=33012

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

                    one-reply-to-this-post last-reply-time reply quote 0
                    • K Offline
                      kwalkerman
                      last edited by

                      The reason that your while loops are crashing SU is that, in basic terms, any time ruby is running, SU is not running. The scripts that appear to run continuously while SU is running are alerted or activated by something. The ruby code executes, completes, and waits for until it is called again. There are different things that can call ruby code to execute. For example, many tools respond to an onMouseMove method, so they update every time the mouse is moved. Other scripts respond to observers. Your example of a while loop is a classic example of an infinite loop. If SU gets caught in an infinite loop (eg. your while loop with no output), it will crash.

                      I hope this helps explains the current problem. I don't have much experience with timers, but read the thread Thom suggested and hopefully you'll find some answers there.

                      Good luck.

                      one-reply-to-this-post last-reply-time reply quote 0
                      • T Offline
                        The Nazgul uk
                        last edited by

                        Thanks for all of the help, im now using a timer which solves the problem perfectly

                        one-reply-to-this-post last-reply-time 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