Plugin running indefinitely
-
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
-
Does your while loop look like this?
i = 0
while i < 5
puts i
end
i += 1 -
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?
-
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?
-
I first tried having a while loop of
while(1)
check text file procedure
endthis 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 -
There is nothing in here I can see the way that it runs repeatedly can someone please help !!
-
What about using a timer?
-
Related topic: http://forums.sketchucation.com/viewtopic.php?f=180&t=33012
-
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.
-
Thanks for all of the help, im now using a timer which solves the problem perfectly
Advertisement