Ruby Hotkeys Plugin?
-
Yes. You are right. Just I have not checked the information given to me
-
I know about the key-emulators.
But I want to achieve this result by means Ruby and Sketchup. Is it not possible? -
@sergey2402 said:
I know about the key-emulators.
But I want to achieve this result by means Ruby and Sketchup. Is it not possible?It is possible to send key-strokes to a PC window which will invoke the linked shortcut - as explained in earlier posts - using tools like Wscript etc...
BUT my question is why do you want to do this ?
You can invoke another tool within your own tool by using a reference to that tool rather than needing to shortcut key to it ??
SO for example if your own tools need to change to run 'PipeAlongPath' at some point then simply add the test and thenpipe_along_path()
[it's an old script not well written!] or if you want to add a 'WorkPlane' you'd useWorkPlane.new()
or some tools like my 'TextureRotate' tool will either run as a tool giving a dialog for you to give an angle... BUT if called from within another script with an appropriately [pre]selected face and an angle they'll run as part of the second tool's code... e.g.TextureTools::Rotate.new()
opens the dialog [assuming one face is selected]...
BUT if you were to have several faces 'selected' in your own tool you can iterate through the array of faces and then clear the model selection and add each face in turn, usingTextureTools::Rotate.new(90.0)
to rotate the texture of every face 90 degrees - on completion you are still in your tool and can do other things as desired...
Get each appropriate activation code from the third=party tool's menu definitions or help notes etc...
You might also want to 'require' the third-party scripts to ensure they are loading...
You can't readily jump back into your code if the new tool exits it because it's not written for 'inclusion' [unlike TextureRotate which was!]... however, you can use convoluted observers to check for tool-changes etc and re-run your code from a point after the other tool is done ? ...
However, an easier way if the third-party tool doesn't favor 'inclusion' would be to write your own methods to make say a 'def pipe_along_path(radi,rado,path)
' method within your own tool and invoke that methods as needed, passing the radii and array of path edges etc - you simply find the parts of the code in any third-party tool's that you wish to 'borrow' and rewrite them as needed - always remembering to credit other authors where appropriate... -
@tig said:
... BUT my question is why do you want to do this ? ...
OK. I will tell you a little story.
My friend (F) said to me (M) recently:
(F) I have on the toolbar buttons of SketchUp at the top 4 rows of icons , bottom - 1 row, left 2 columns and right 1 column
I do not need so much.
In these plugins I use only one or two icons (maybe three - but no more).
Why do I need to keep unwanted toolbar icon?
I know - it is possible to see the text of each script, find the command that it does and write a new script for the icon on the toolbar for this command.
But I'm not a programmer. And I can’t and I don’t want find at the other people's scripts rows with those commands.
And I do not know how to write Ruby scripts.(M) And what do you want from me?
(F) I can define in SketchUp hotkeys for commands necessary to me.
And you should write a new Ruby script that would be emulated press these hot keys (such as "Shift+Ctrl+A.rb" and "Shift+Ctrl+B.rb" and "Shift+Ctrl+C.rb", ect, but not "Shift+Ctrl+E.rb" or “H.rb” and so on, because those are internal commands of SketchUp). And these new scripts must be in the form of an icons on the toolbar.(M) BUT why would you want to do this??
(F) Then I can assign hotkeys (to plugins, that I need) and leave them on the toolbar (your new icon), and the all unwanted icons (top 4 rows, bottom 1 row, etc) I will hide.
And the lines in your new scripts (e.g. cmd.tooltip = "Shift + Ctrl + A") I'll be able to change myself by e.g. cmd.tooltip = "run plugin X". And the icons in your new folder "My Icons" I'll be able to change myself, too.(M) And then what?
(F) 1. And then - on my toolbar is only one row with the required icons.
2. And then - when I want I can quickly redefine hotkeys for the other plugins (if there is a newer or better version from another programmer).
3. And then - I can have icons for plugins that do not have icons.
4. And then - any user (not programmer) will be able very easy to create your personal toolbar.
5. And so on...(M) Well, I'll ask on the forum sketchucation.com - is it possible to do so?
And so I ask - is it possible to do so?
-
I think you are approaching this from the wrong direction...
You are really looking to make a customized toolbar.
This has already been done.
You can set up a toolbar by a global reference [$] and add buttons to it as needed at startup, even from another script...
Provided you read [usually] the final parts of a .rb script for the toolbar making code you can see how to add the 'commands' to a toolbar - including your own.
If you want to make a shortcut key-combo to a tool it's straightforward provided the tool has a menu item etc that you can link to - including your own which can just be a list of tools in a submenu...
To disable a tool's own menu/toolbar etc put # in front of the relevant line[s] or =begin...=end for larger blocks of code. The tool's code will still load but without a menu/toolbar until used in your own menu/toolbar...
I'm still not sure what the advantages are to you in doing it in this other seemingly excessively convoluted manner, which could be possible [OS dependent] but of less benefit that the effort warrants... -
Thank you. I will tell my friend - it's impossible. Forget about it.
Advertisement