sketchucation logo sketchucation
    • Login
    โ„น๏ธ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Send string value to Webdialog

    Scheduled Pinned Locked Moved Developers' Forum
    7 Posts 4 Posters 327 Views 4 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.
    • P Offline
      Pout
      last edited by

      This is how it can be done (besides JSON)

      Example.

      In ruby

      name="blablabla"
      command = "_showdata('taskname', '#{name}')"
      dialog.execute_script(command)
      

      In webdialog

      function _showdata(id,value) {
      	var element = document.getElementById(id);
      	element.value = value; 
        	}
      

      The only problem i have is:
      Ruby continues interpreting script without waiting.
      For example: if the dialog is not yet open, you test on that and first open the dialog, the value will not be shown in the dialog. App. the ruby script just continues without waiting tille the dialog is open. Now if i place a UI.messagebox just before the command line all goes well.

      Is there any way to hold the ruby script so it only continues if the dialog script is executed? Or is there another way to do this?

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

        I suppose you could make up an array of commands that would stack up if the webdialog isn't open. Then, when it does loop through and send them.

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

        1 Reply Last reply Reply Quote 0
        • J Offline
          Jim
          last edited by

          Maybe use the show{} method to defer execution?

          
          dlg = WebDilaog.new(...)
          #... 
          dlg.show {
            # your code here
          }
          
          
          

          Hi

          1 Reply Last reply Reply Quote 0
          • chrisglasierC Offline
            chrisglasier
            last edited by

            If you are going to open a web dialog I would recommend you always control the action from the dialog's javascript - onload call ruby callback > receive ruby execute script.

            Chris

            With TBA interfaces we can analyse what is to be achieved so that IT can help with automation to achieve it.

            1 Reply Last reply Reply Quote 0
            • P Offline
              Pout
              last edited by

              Hey Chris,

              Do you have an example for me?
              Thanks!

              1 Reply Last reply Reply Quote 0
              • chrisglasierC Offline
                chrisglasier
                last edited by

                Open transformations.zip from here.

                Let me know if you have any problems.

                Chris

                edit: in my last post there

                With TBA interfaces we can analyse what is to be achieved so that IT can help with automation to achieve it.

                1 Reply Last reply Reply Quote 0
                • P Offline
                  Pout
                  last edited by

                  ok i'll look into it ๐Ÿ˜„
                  Thanks!

                  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