How to launch a ruby script with OnClick?
-
Hello,
Actually I want to launch a Ruby script when I click on a dynamic objet.
It's possible with the function "onclick", to put a ruby file in parameter?
Or if you know how i can do this plz with an other function.
thx
Pauline
-
Hi Pauline,
I do not believe it is possible unless you create your own Tool to do it.
One option is to use put a link in the Component Options window for the Dynamic Component.
-
@pauline01 said:
It's possible with the function "onclick", to put a ruby file in parameter?
Your Ruby creates a WebDialog, assigns your HTML (with embedded CSS and JavaScript, or links to .css and .js files) and launches it. The click handling code in your WebDialog's JavaScript can call an action callback in your Ruby code, passing a message string. That string could be the name of another Ruby program to load or your Ruby functionality could be embedded in the callback routine. (The message could also be actual Ruby code to execute, but there's a 2KB length restriction.)
Try:
http://www.martinrinehart.com/models/rubies/ruby2javascript_javascript2ruby.html -
With this method i can take a parameter of my dynamic objet (adress, type, lenght ect ect for example)draw in sketchup and to pass this in my ruby script or other?I need informations of my dynamic objet to do some SQL query.It's possible?
Sorry for my bad english^^ et thank for informations
-
I guess you need this.
Sent at: Mon Oct 12, 2009 5:16 pm
From: NewOne
To: Pauline01This is how you use ruby Mysql with SketchUp: http://forums.sketchucation.com/viewtopic.php?f=180&t=19719
You can not update sketchup ruby interpreter, nor add gems in classic way, but if you add proper files and make the requirements, you can use extra functionality.if one it's interessed.
-
I think you want to use a SelectionObserver
http://code.google.com/apis/sketchup/docs/ourdoc/selectionobserver.html
Whenever a new object is added to the selection you can run some code.
-
ok thx i go test!
-
@martinrinehart said:
The message could also be actual Ruby code to execute, but there's a 2KB length restriction.
I am sorry but I think this is misleading and my mother tongue is English. Is this what you are talking about?
http://code.google.com/apis/sketchup/docs/ourdoc/webdialog.html
@unknownuser said:
Note that you're sending data down to Ruby as a single string that's passed via the window.location bar. In Internet Explorer on PC, there is a length limit of 2038 characters for this bar, so if you're needing to pass large data down you might consider using get_element_value to pull in a longer string from a hidden input field in the HTML.
Advertisement