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

    Plugin infinite loop (intentional) causes Sketchup to hang

    Scheduled Pinned Locked Moved Newbie Forum
    sketchup
    4 Posts 2 Posters 243 Views 2 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.
    • U Offline
      udpsocketlover
      last edited by

      Hey,

      So, I'm running the following code within a *.rb file":

      UI.menu("Plugins").add_item("Test"){
      	sleep 1
      	puts "Testing"
      	counter = 0
      	while true do
      		puts counter
      		counter = counter + 1
      		sleep 1
      	end
      }
      

      This is a simple script to just test the capabilities.

      What happens, is that SU becomes unresponsive while this is running (which makes sense), but I'm curious as to how people get plugins to run code constantly. My end project is a plugin which receives real-time data and acts upon it, so this small step is very important.
      Any help is appreciated and sorry if it seems like a silly question, thanks!

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

        I think that there are basically three ways to run things outside of the main process...

        . Various Observers watch in the background waiting for some event to trigger an action.
        ' UI class timer runs a process in parallel.
        ' Animation class runs in parallel affecting the camera [typically]...

        What sort of 'continual process' did you have in mind ?

        TIG

        1 Reply Last reply Reply Quote 0
        • U Offline
          udpsocketlover
          last edited by

          Basically, I'll be receiving a string via TCP constantly, interpreting the string, and then drawing shapes based upon the string. I don't think that falls into any of those categories, am I out of luck?

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

            The fourth possibility... 😒
            Use a webdialog to receive your data-stream, running callbacks that do something inside the SKP...
            There are a few video examples, if you search the web.
            I've seen stock-prices streamed in to make a webdialog [off-screen] draw a 3d block graph in real time...
            Perhaps start looking from here https://sites.google.com/site/sketchupsage/resources

            TIG

            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