• Login
sketchucation logo sketchucation
  • Login
⚠️ Libfredo 15.4b | Minor release with bugfixes and improvements Update

How to launch a ruby script with OnClick?

Scheduled Pinned Locked Moved Developers' Forum
8 Posts 5 Posters 1.3k Views 5 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.
  • P Offline
    Pauline01
    last edited by 12 Oct 2009, 12:22

    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

    1 Reply Last reply Reply Quote 0
    • J Offline
      Jim
      last edited by 12 Oct 2009, 13:34

      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.

      Hi

      1 Reply Last reply Reply Quote 0
      • M Offline
        MartinRinehart
        last edited by 12 Oct 2009, 13:59

        @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

        Author, Edges to Rubies - The Complete SketchUp Tutorial at http://www.MartinRinehart.com/models/tutorial.

        1 Reply Last reply Reply Quote 0
        • P Offline
          Pauline01
          last edited by 12 Oct 2009, 14:54

          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

          1 Reply Last reply Reply Quote 0
          • P Offline
            Pauline01
            last edited by 12 Oct 2009, 15:29

            I guess you need this.
            Sent at: Mon Oct 12, 2009 5:16 pm
            From: NewOne
            To: Pauline01

            This 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.

            1 Reply Last reply Reply Quote 0
            • C Offline
              CPhillips
              last edited by 12 Oct 2009, 18:13

              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.

              1 Reply Last reply Reply Quote 0
              • P Offline
                Pauline01
                last edited by 14 Oct 2009, 06:15

                ok thx i go test!

                1 Reply Last reply Reply Quote 0
                • C Offline
                  chrisglasier
                  last edited by 14 Oct 2009, 07:56

                  @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.

                  With TBA interfaces we can analyse what is to be achieved so that IT can help with automation to achieve it.

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

                  Advertisement