sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    How do I run send_action for a custom menu item

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 2 Posters 450 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.
    • W Offline
      willanie
      last edited by

      Ive read most of the posts describing the built in items available with send_action but how do I do this for a new custom menu item.
      Say I installed a custom plugin called NewExtension and one of the menu items is Doit.
      What I want is something like
      Sketchup.send_action "Plugins/NewExtension/Doit:"

      Is that possible? Or is there some other way to execute this custom menu item within a ruby script?

      1 Reply Last reply Reply Quote 0
      • TIGT Offline
        TIG Moderator
        last edited by

        You cannot access such menu items that way...
        However, since you know what command the menu item itself 'runs' you can access that directly in any other script...

        Just repeat the same code that is in the menu item...
        It depends how your code is constructed...
        For example...

        cmd = UI::Command.new('NewExtension-Doit'){ NewExtension.new() } UI.menu('Plugins').add_item(cmd)

        OR if you are not making a command for a toolbar, perhaps

        UI.menu('Plugins').add_item('NewExtension-Doit'){ NewExtension.new() }

        If it's a 'Tool' you need to use a different syntax for the last part, like:

        Sketchup.active_model.select_tool(NewExtension.new())

        TIG

        1 Reply Last reply Reply Quote 0
        • W Offline
          willanie
          last edited by

          Thanks for the reply Tig.
          I don't know what code the menu item runs. I would like to simulate, with a ruby command, that I had clicked on a menu item in this pre-installed custom extension.
          Am I missing something in your suggestion?

          1 Reply Last reply Reply Quote 0
          • TIGT Offline
            TIG Moderator
            last edited by

            You can't use the script's code if it's inside an encrypted RBS, but if the Extension menu/toolbar-maker is in a RB, then you can read it to see what it's doing...

            You have to do some detective work...
            If we knew this 'secret' extension then we could comment more constructively 😒

            TIG

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

            Advertisement