sketchucation logo sketchucation
    • Login
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    WebDialog Javascript callback Maximum message size

    Scheduled Pinned Locked Moved Developers' Forum
    9 Posts 6 Posters 2.5k Views 6 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.
    • M Offline
      mocathe1st
      last edited by

      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
      • AdamBA Offline
        AdamB
        last edited by

        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

          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

            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

              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

                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

                  @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

                    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

                      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
                      • First post
                        Last post
                      Buy SketchPlus
                      Buy SUbD
                      Buy WrapR
                      Buy eBook
                      Buy Modelur
                      Buy Vertex Tools
                      Buy SketchCuisine
                      Buy FormFonts

                      Advertisement