Webdialog: html and rb example
-
Hello,
I'm hardly trying to open a webdialog that could send parameters to an entity in sketchup. This entity could be "as simple as creating a box" that would be defined from a html form (width, length, height).
I can't get how to retrieve variables from html (or even what exactly to do from SU...)
Has Someone an example of the simpliest webdialog use with both sources in .rb and .html?Thank you.
Emmanuel
-
I get 4 pages of hits on this forum for "webdialog". Did none of those give you a clue?
-
You are right, 4 pages that i read before posting it.
but 4 pages mostly on how to center the webdialog window, it doesn't help.
At least one inspired my new post,
http://www.sketchucation.com/forums/scf/viewtopic.php?f=57&t=5958&p=35329&hilit=+webdialog#p35329
But Koos' concern is far away from mine... At this moment I wouldn't mind if my webdialog would stay active, I simply want to communicate between a html file and sketchup using ruby.Any Idea?
-
Hello,
I'm trying to take advantage of this code below, that I found here (Todd was right... well, almost)
That's the html file
<HTML> <HEAD> <title>Webdialog UI </title> <style type="text/css"> </style> </HEAD> <body> <div> <p><font color="blue">Input</font><br> <input type="text" name="myTextInput" size="24"></input> </p> <p><input type="submit" name="submitButtonName" onclick="tellSketchup(myTextInput.value)"></p> </div> <script type="text/javascript"> function tellSketchup(value) { //this non-intuitive command will call the sketchup function "ValueChanged" //with the name and value of the control that changed window.location='skp;ValueChanged@'+ value; } </script> </body> </HTML>
and here is the .rb file
def inputSimple() #create dlg = UI;;WebDialog.new("inputSimple", true,"inputsimple", 300, 300, 100, 50, true) fn= File.dirname(__FILE__)+'/inputsimple.html' dlg.set_file fn dlg.show {} dlg.add_action_callback("ValueChanged") {|d,p| puts p dlg.close {} } end
But I can't achieve what I'm looking for: getting integer from the webdialog and use it to draw a box (f.e)
to do so i'm trying to
- Call another def at the end of the inputSimple()
- Use the input as a variable in this called def;
- Use multiple inputs
But I do not succeed.
Can someone help? -
Hello,
So far, i've solved my problem to call a def by using,
dialog.set_on_close { def_to_run }
For the unique variable to use, I've inserted in the dlg.add_action_callback
$insertinput = p
and then convert my $insertinput.to_i (not sure if I must set my variable in global)
So I still have no solution to manipulate more than one text string form my webdialog form.
How could I get different and multiple text boxes to send to sketchup 3 or more different variables?Thanks!
-
Try this search argument:
http://groups.google.com/group/Ruby-API/search?group=Ruby-API&q=webdialog&qt_g=Search+this+category
Todd
Advertisement