• Login
sketchucation logo sketchucation
  • Login
🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

Plugin running indefinitely

Scheduled Pinned Locked Moved Developers' Forum
10 Posts 6 Posters 521 Views
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
    The Nazgul uk
    last edited by 20 Nov 2010, 01:21

    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

    1 Reply Last reply Reply Quote 0
    • B Offline
      Brett McAllister
      last edited by 20 Nov 2010, 04:52

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

      1 Reply Last reply Reply Quote 0
      • T Offline
        thomthom
        last edited by 20 Nov 2010, 08:43

        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

        1 Reply Last reply Reply Quote 0
        • C Offline
          Chris Fullmer
          last edited by 20 Nov 2010, 09:04

          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

          1 Reply Last reply Reply Quote 0
          • T Offline
            The Nazgul uk
            last edited by 20 Nov 2010, 19:09

            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

            1 Reply Last reply Reply Quote 0
            • T Offline
              The Nazgul uk
              last edited by 30 Nov 2010, 18:44

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

              1 Reply Last reply Reply Quote 0
              • J Offline
                Jim
                last edited by 1 Dec 2010, 12:49

                What about using a timer?

                Hi

                1 Reply Last reply Reply Quote 0
                • T Offline
                  thomthom
                  last edited by 1 Dec 2010, 13:03

                  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

                  1 Reply Last reply Reply Quote 0
                  • K Offline
                    kwalkerman
                    last edited by 3 Dec 2010, 15:50

                    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.

                    1 Reply Last reply Reply Quote 0
                    • T Offline
                      The Nazgul uk
                      last edited by 3 Dec 2010, 23:52

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

                      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