Question - A way to allow user to change ruby menu location?
-
I was wondering if the is a way for a script (particulary those that are protected in .rbs format) to change which SU menu the script appears in?
I understand how to manually manipulate most .rb's, but it would be very convenient if a standard block of code be developed which would allow the user, on the fly, to change the Menu they'd like the script to appear in. Perhaps be a standalone file in the plugin directory which a script could make a call to?
Regards, John
P.S. I realize there ways to reorganize the scripts into a custom UI, but I thought there might be a simpler way of organizing scripts utilizing the existing/out-of-the-box SU Menus.
-
Difficult. You can't change it while Sketchup is running -> restart. But you can try to override the Sketchup methods for adding (sub) menus and menu items keeping the old methods with alias names. Your methods "hook" into the old methods, before they perform their action - short IRB session explaining what I'm talking about:
irb(main);001;0> class A irb(main);002;1> def a irb(main);003;2> puts "a" irb(main);004;2> end irb(main);005;1> end => nil irb(main);006;0> class A irb(main);007;1> alias ;old_a ;a irb(main);008;1> def a irb(main);009;2> puts "b" irb(main);010;2> old_a irb(main);011;2> end irb(main);012;1> end => nil irb(main);013;0> A.new.a b a => nilYour method could read the correct menu structure i.e. from a text file. But you have to make sure, that your script is eval'ed by Sketchup before another script adds menus or menu items.
azuby
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register LoginAdvertisement