• Login
sketchucation logo sketchucation
  • Login
ℹ️ GoFundMe | Our friend Gus Robatto needs some help in a challenging time Learn More

WebDialog Javascript callback Maximum message size

Scheduled Pinned Locked Moved Developers' Forum
9 Posts 6 Posters 2.5k 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.
  • M Offline
    mocathe1st
    last edited by 4 Apr 2008, 15:55

    Hi all,

    I just found out today that the maximum message size for passing a Javascript callback to SketchUp is 2083 characters as this is the max url size in Internet Explorer (I think its more like 80000 in Safari, so this is limited to the Windows version of Safari). This is extremely annoying as I'm currently working on a project where I have to pass XML data between SketchUp and my plugin and this is causing all manner of problems. 😢

    I was just wondering if anyone knows of any other methods of passing data to a to SketchUp via the WebDialog other than passing messages into the URL?

    1 Reply Last reply Reply Quote 0
    • A Offline
      AdamB
      last edited by 4 Apr 2008, 17:04

      Why don't you just send it in smaller junks with a simple handshake protocol? The receiver just accumulates pieces until its got the whole thing.

      Adam

      Developer of LightUp Click for website

      1 Reply Last reply Reply Quote 0
      • C Offline
        CPhillips
        last edited by 5 Apr 2008, 01:35

        For getting data from a Webdialog you might be able to use get_element_value. For me that works better than using skp: The skp: method cant handle certain characters.

        I have no solution for sending to a dialog. I wish there was a set_element_value.

        1 Reply Last reply Reply Quote 0
        • R Offline
          RickW
          last edited by 5 Apr 2008, 23:09

          CPhillips is right - you need to put the data into an element in the webdialog, then use get_element_value.
          The "set_element_value" is disguised as "execute_script". It allows you to execute a block of javascript in the webdialog from your ruby script.

          webdialog.execute_script("document.getElementById(\"myElementID\").innerHTML=\"<XML CODE GOES HERE>\"")
          

          It's a wild concept, but there it is...

          RickW
          [www.smustard.com](http://www.smustard.com)

          1 Reply Last reply Reply Quote 0
          • J Offline
            Jim
            last edited by 6 Apr 2008, 00:04

            It's trivial to write a set_element_value, no?

            Hi

            1 Reply Last reply Reply Quote 0
            • T Offline
              todd burch
              last edited by 6 Apr 2008, 13:12

              Should be. I'll pull the developer's chain to see what they can do!

              Good idea - #set_element_value.

              Todd

              1 Reply Last reply Reply Quote 0
              • J Offline
                Jim
                last edited by 6 Apr 2008, 14:17

                @unknownuser said:

                Should be. I'll pull the developer's chain to see what they can do!

                Good idea - #set_element_value.

                Todd

                That's cool, but I was just thinking in Ruby.

                
                def dlg.set_element_value(id, val)
                  dlg.execute_script(%(document.getElementById("#{id}").innerHTML="#{val}"))
                end
                
                
                • The %() is good way to quote strings, if the strings need double-quotes. You can use any delimiter:
                
                v = 10
                %(This is a string with v=#{v} and "quotes")
                %/This is "the same", a string with v=#{v}/
                
                

                Hi

                1 Reply Last reply Reply Quote 0
                • M Offline
                  mocathe1st
                  last edited by 7 Apr 2008, 09:47

                  Hi,

                  Thanks for your replies. I don't know what I'd do without this forum for help... 😄

                  I'll try creating a hidden div to hold the XML and use the get_element_value to retrieve it from SketchUp. I'll let you know if it works for me.

                  Thanks again,

                  Malcolm

                  1 Reply Last reply Reply Quote 0
                  • C Offline
                    CPhillips
                    last edited by 7 Apr 2008, 19:04

                    Be advised that execute_script is very buggy on Mac. It will mangle the string sent if it contains ";" or "," and probably other chars as well. Also "document." doesnt work. 😞

                    1 Reply Last reply Reply Quote 0
                    • 1 / 1
                    1 / 1
                    • First post
                      9/9
                      Last post
                    Buy SketchPlus
                    Buy SUbD
                    Buy WrapR
                    Buy eBook
                    Buy Modelur
                    Buy Vertex Tools
                    Buy SketchCuisine
                    Buy FormFonts

                    Advertisement