sketchucation logo sketchucation
    • Login
    πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Update a WebDialog

    Scheduled Pinned Locked Moved Developers' Forum
    8 Posts 5 Posters 536 Views 5 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
      tomasz
      last edited by

      Hi,
      Is there a way to give a WebDialog enought time to let it update. I mean a 'progress bar' scenario when ruby is doing something and the WD needs to be updated. As far as I know WDs sit on the same thread as Ruby ... I guess it will be hard to force the update.

      Author of [Thea Render for SketchUp](http://www.thearender.com/sketchup)

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

        I think a few people has tried this - without much luck.

        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
          tomasz
          last edited by

          😞
          So we should file a feature request to have web_dialog.refresh method added.

          Author of [Thea Render for SketchUp](http://www.thearender.com/sketchup)

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


            Did you try to use Js to refresh the html ??

            PC MSIE [window.location.reload()](http://msdn.microsoft.com/en-us/library/ms536691(v)

            reload from browser cache:
            dlg.execute_script("window.location.reload(false)")

            reload from file:
            dlg.execute_script("window.location.reload(true)")

            The MSDN page says, "Standards Information: There is no public standard that applies to this method."
            So this may be a MSIE only method.

            I do NOT know if it will work on Mac Safari.
            .
            See also:
            [window.location.assign](http://msdn.microsoft.com/en-us/library/ms536342(v)
            [window.location.replace](http://msdn.microsoft.com/en-us/library/ms536712(v)

            I'm not here much anymore.

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

              @dan rathbun said:


              Did you try to use Js to refresh the html ??

              That'd just require even more cycles - and it'd cancel out any HTML changes made by JS since it was first loaded.

              The problem is that the webdialog is not allowed any CPU time to update it's UI until after the Ruby loop that's processing is done.

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

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

                @thomthom said:

                @dan rathbun said:


                Did you try to use Js to refresh the html ??

                That'd just require even more cycles - and it'd cancel out any HTML changes made by JS since it was first loaded.

                Well I didn't go into detail.. but you would need to pass anything (vars) that you want to save over to the Ruby side... the page init Js function would request the values again from the Ruby side, same as it did on the initial load, for the default values.

                @thomthom said:

                The problem is that the webdialog is not allowed any CPU time to update it's UI until after the Ruby loop that's processing is done.

                So they don't run in a new process huh ? But the Ruby loop, could have embedded execute_script calls to periodically give the WD cycles ??

                I'm not here much anymore.

                1 Reply Last reply Reply Quote 0
                • N Offline
                  niccah
                  last edited by

                  Hey guys!

                  I have to pick up this topic again!

                  My problem: I have a WebDialog to create "Tools" - when a user created a new Tool, one has to update the webdialog.

                  In my case, it looks like this:

                  
                  html = " .... "
                  	dlg = UI;;WebDialog.new("Model2GCode - Tools", true, "Model2GCode - Tools", 800, 300, 50, 50, true);
                  	dlg.set_html html
                  	dlg.show
                  	
                  	dlg.add_action_callback("saveNewTool") {
                  
                  }
                  
                  

                  Is there a possibility to close the WbDialog, "jump" to the start of the script and open it again? I tried a lot, but I didn't get a running solution.

                  Thanks for all your help!

                  1 Reply Last reply Reply Quote 0
                  • D Offline
                    Diggsey
                    last edited by

                    Your first problem is very easy to solve, just make sure that your ruby script executes asynchronously.
                    I use this function in a couple of my scripts instead of the outer-most loop:

                    
                    	def asyncLoop(range, &proc)
                    		from = range.min
                    		to = range.max
                    		iteration = lambda do |index|
                    			last = (index > to)
                    			
                    			proc.call(index, last)
                    			
                    			if !last then
                    				UI.start_timer(0.02, false) { iteration.call(index.succ) }
                    			end
                    		end
                    		
                    		iteration.call(from)
                    		
                    		return nil
                    	end
                    
                    

                    You can use it like this:

                    
                    		asyncLoop(0...16) do |i, last|
                    			if (!last) then
                    				# Perform ith iteration
                    			else
                    				# Put code to be run after this operation here instead of outside the loop
                    			end
                    		# Code here will run immediately, so leave it empty
                    
                    
                    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