WebDialog Javascript callback Maximum message size
-
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?
-
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
-
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.
-
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...
-
It's trivial to write a set_element_value, no?
-
Should be. I'll pull the developer's chain to see what they can do!
Good idea - #set_element_value.
Todd
-
@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,
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
-
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.
Advertisement