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

Ruby Hotkeys Plugin?

Scheduled Pinned Locked Moved Developers' Forum
26 Posts 5 Posters 3.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.
  • S Offline
    sergey2402
    last edited by 2 Jul 2011, 02:35

    Can I through the Ruby script to execute the command, appointed in Sketchup on "hot keys"?
    For example.
    I have a plugin “Weld”. And for him I have “hotkeys” Ctrl+W.
    Then in the Ruby Console I do - "execute Ctrl+W " and will execute the plugin “Weld”.
    Is it possible?

    1 Reply Last reply Reply Quote 0
    • J Offline
      Jim
      last edited by 2 Jul 2011, 02:47

      To exeute the weld plugin, you would enter "join_edges" in the Ruby Console because the name of the method which weld defines is named join_edges.

      Look for the UI.menu() {} code in other plugins to find the name to use to call from the Ruby Console.

      Hi

      1 Reply Last reply Reply Quote 0
      • S Offline
        sergey2402
        last edited by 2 Jul 2011, 03:46

        I mean another thing.
        It does not matter which plug-in to execute. Maybe "Weld", maybe "Beld" or maybe "Weld-Beld". Does Ruby ability to perform the command associated with the "hotkeys" assigned to Sketchup?
        I don't want to know the name of the method, which plugin defines. I only know one thing - "hotkeys", which I defined in Sketchup, the plugin can be arbitrary.

        1 Reply Last reply Reply Quote 0
        • J Offline
          Jim
          last edited by 2 Jul 2011, 03:51

          Then no. At least not without this: http://code.google.com/p/eventrelay/

          Hi

          1 Reply Last reply Reply Quote 0
          • S Offline
            sergey2402
            last edited by 2 Jul 2011, 05:13

            Thank you. I'll try it

            1 Reply Last reply Reply Quote 0
            • S Offline
              sergey2402
              last edited by 3 Jul 2011, 22:15

              Is there a theoretical possibility to write the text of Ruby-script, which emulated a pressing hotkeys defined in the SketchUp by the user?

              1 Reply Last reply Reply Quote 0
              • T Offline
                TIG Moderator
                last edited by 3 Jul 2011, 22:17

                @sergey2402 said:

                Is there a theoretical possibility to write the text of Ruby-script, which emulated a pressing hotkeys defined in the SketchUp by the user?

                On a PC you can use Wscript.shell to simulate specific keystrokes... BUT why would you want to do this ??

                TIG

                1 Reply Last reply Reply Quote 0
                • D Offline
                  Dan Rathbun
                  last edited by 3 Jul 2011, 22:58


                  use the Sketchup.send_action method.

                  I'm not here much anymore.

                  1 Reply Last reply Reply Quote 0
                  • S Offline
                    sergey2402
                    last edited by 4 Jul 2011, 01:34

                    @dan rathbun said:

                    use the Sketchup.send_action method.

                    I know some of numeric values applied to “Sketchup.send_action( )"

                    For example, some of them:
                    10527: "Shift+Ctrl+E"
                    10526: "Shift+Ctrl+W"
                    -7892: "Ctrl+Y"
                    21101: "Ctrl+A"
                    21065: "A"
                    21096: "C"
                    21019: "E"
                    21074: "B"

                    And so on…

                    But I don’t know the numeric values for the key combination, for example, "Shift+Ctrl+A" or "Shift+Ctrl+B" or "Shift+Ctrl+C", etc.

                    Where can I find numeric values for these (and similar) key combination?

                    1 Reply Last reply Reply Quote 0
                    • S Offline
                      sergey2402
                      last edited by 4 Jul 2011, 01:36

                      @tig said:

                      BUT why would you want to do this ??

                      I will answer your question. But, with my “excellent knowledge of English”, I'll be a long time to formulate my ideas.

                      1 Reply Last reply Reply Quote 0
                      • D Offline
                        Dan Rathbun
                        last edited by 4 Jul 2011, 03:11

                        @sergey2402 said:

                        Where can I find numeric values for these (and similar) key combination?

                        Numeric arguments only work on Windows, not on Apple Mac.

                        Concentrate on the command (not the key combos,) and use the string arguments for send_action.

                        Example: Ctrl+Shift+W = Camera Zoom Window, so:

                        Sketchup.send_action("selectZoomWindowTool:")

                        Any user can change the shortcut key combos for commands.

                        I'm not here much anymore.

                        1 Reply Last reply Reply Quote 0
                        • S Offline
                          sergey2402
                          last edited by 4 Jul 2011, 06:20

                          @dan rathbun said:

                          Numeric arguments only work on Windows, not on Apple Mac.

                          Concentrate on the command (not the key combos,) and use the string arguments for send_action.

                          Example: Ctrl+Shift+W = Camera Zoom Window, so:

                          Sketchup.send_action("selectZoomWindowTool:")

                          Any user can change the shortcut key combos for commands.

                          Thank you very much for you paid me attention. But my question is different.
                          Where can I find numeric values for these ("Shift+Ctrl+A" or "Shift+Ctrl+B" or "Shift+Ctrl+C") key combination?

                          1 Reply Last reply Reply Quote 0
                          • thomthomT Offline
                            thomthom
                            last edited by 4 Jul 2011, 08:33

                            @sergey2402 said:

                            In a nutshell - the ultimate goal to create a Ruby script called "hotkeys buttons on the toolbar"
                            I mean, hotkeys are not built into SketchUp. I mean user-defined any hotkeys for any plugins.

                            ?
                            You can define hotkeys for any menu or toolbar element - that include those the belongs to ruby scripts?

                            Thomas Thomassen — SketchUp Monkey & Coding addict
                            List of my plugins and link to the CookieWare fund

                            1 Reply Last reply Reply Quote 0
                            • S Offline
                              sergey2402
                              last edited by 4 Jul 2011, 09:22

                              @thomthom said:

                              ?
                              You can define hotkeys for any menu or toolbar element - that include those the belongs to ruby scripts?

                              Sorry, I do not understand. That was the question? Or was it your help?
                              Of course, my English is "excellent", but I understand it is very bad. 😳

                              1 Reply Last reply Reply Quote 0
                              • S Offline
                                sergey2402
                                last edited by 4 Jul 2011, 09:26

                                @tig said:

                                BUT why would you want to do this ??

                                In a nutshell - the ultimate goal to create a Ruby script called "hotkeys buttons (or icons) on the toolbar"
                                I mean, hotkeys are not built into SketchUp. I mean user-defined any hotkeys for any plugins.

                                1 Reply Last reply Reply Quote 0
                                • T Offline
                                  TIG Moderator
                                  last edited by 4 Jul 2011, 09:36

                                  Window > Preferences > Shortcuts
                                  Filter for the tool/ruby required.
                                  Set shortcut key[s] to it.
                                  Note that some items only appear in the list if there is a suitable selection - e.g. to shortcut to 'Reverse' face as seen in the context-menu, you must first select a face then open Preferences - if no face is selected then the 'Reverse' doesn't appear in the available items to shortcut to...
                                  Provided your plugin has some sort of menu presence you can shortcut to it by 'name'...

                                  TIG

                                  1 Reply Last reply Reply Quote 0
                                  • J Offline
                                    Jim
                                    last edited by 4 Jul 2011, 14:10

                                    Serge, you are talking about Windows Automation with Ruby .

                                    The "Ruby Way" is to use the Ruby Win32ole library . (Search Ruby Gems about using Ruby libraries in SketchUp-Ruby.)

                                    Alternative to win32ole, some plugins use the WShell.SendKeys() from a .vbs script to do the automation. (I use this in Save as Previous Version .) Windows Powershell can also use the SendKeys function to automate Windows.

                                    There is no "perfect" solution.

                                    Hi

                                    1 Reply Last reply Reply Quote 0
                                    • S Offline
                                      sergey2402
                                      last edited by 5 Jul 2011, 19:59

                                      @jim said:

                                      Serge, you are talking about Windows Automation with Ruby .

                                      Unfortunately, for me it is too difficult. I'm just a civil engineer, not a programmer. I really like SketchUp and I found it very useful. I just want a little to tweak it for me...

                                      1 Reply Last reply Reply Quote 0
                                      • S Offline
                                        sergey2402
                                        last edited by 5 Jul 2011, 20:07

                                        In the menu Window > Preferences > Shortcuts I redefined the letter "H" from the “Camera/Pan” to plugin “Pipe Along Path”.

                                        I drew the lines, selected them and pressed on the keyboard the letter “H”.
                                        Plugin “Pipe Along Path” been executed. BINGO!

                                        I drew the lines again, selected them and run Window > Ruby Console.

                                        In the Ruby console I wrote a string “Sketchup.send_action 10523” and pressed Enter
                                        (I know - the value of 10 523 corresponds to the letter “H”)

                                        And what I see as a result?

                                        I see a HAND (Camera/Pan)!!!

                                        What nonsense is going on?

                                        1 Reply Last reply Reply Quote 0
                                        • T Offline
                                          TIG Moderator
                                          last edited by 5 Jul 2011, 21:09

                                          What makes you think that 'Sketchup.send_action 10523' is an 'H' ???
                                          10523 == 'Moves the camera viewpoint while maintaining view direction' [PC only!!]
                                          Remapping a shortcut key has no connection whatsoever with that key's previously linked command ???
                                          You've simply changed 'H' to be the shortcut key for 'PipeAlongPath'...
                                          The 'send_action' still calls the fixed linked-command!
                                          IF you want to use the 'H' to execute its linked-command use a Wscript or similar key-emulator BUT, oh BUT, why are you trying to do this weirdness ?????
                                          Why not simply invoke PipeAlongPath directly ???

                                          TIG

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

                                          Advertisement