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

Question - A way to allow user to change ruby menu location?

Scheduled Pinned Locked Moved Developers' Forum
2 Posts 2 Posters 253 Views 2 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.
  • J Offline
    JClements
    last edited by 8 Jan 2009, 18:29

    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.

    John | Illustrator | Beaverton, Oregon

    1 Reply Last reply Reply Quote 0
    • A Offline
      azuby
      last edited by 9 Jan 2009, 22:53

      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
      => nil
      

      Your 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

      *error initus :: Blocks | CurrentDate | d/Code | extensionmanager | FFlipper | HideEdges | MeasuredArea | ModelHistory | PluginsHelp | PronButton | SAWSO | SCP | SU²CATT

      Bad English? PM me, correct me. :smile:**

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

      Advertisement