sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    🚨 Skimp | 25% Off until March 30 Buy Now

    Create toolbar on the fly

    Scheduled Pinned Locked Moved Developers' Forum
    5 Posts 4 Posters 367 Views 4 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.
    • P Offline
      Pout
      last edited by

      I'm I correct: it is not possible to create a toolbar from in the ruby console using these command?

      toolbar = UI::Toolbar.new "testtoolbar"
      cmd = UI::Command.new("testbutton") {a function }
      cmd.small_icon = "testimage.png"
      cmd.large_icon = "testimage.png"
      cmd.tooltip = ("testfunction")
      cmd.status_bar_text = ("execute testfunction")
      cmd.menu_text = ("execute testfunction")
      toolbar = toolbar.add_item cmd

      The toolbar is created and listed in the toolbars overview but it is not shown.

      1 Reply Last reply Reply Quote 0
      • C Offline
        cjthompson
        last edited by

        toolbar.show?

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

          @pout said:

          I'm I correct: it is not possible to create a toolbar from in the ruby console using these command?

          toolbar = UI::Toolbar.new "testtoolbar"
          cmd = UI::Command.new("testbutton") {a function }
          cmd.small_icon = "testimage.png"
          cmd.large_icon = "testimage.png"
          cmd.tooltip = ("testfunction")
          cmd.status_bar_text = ("execute testfunction")
          cmd.menu_text = ("execute testfunction")
          toolbar = toolbar.add_item cmd
          The toolbar is created and listed in the toolbars overview but it is not shown.

          Note that 'a function' needs to be a proper function.
          The image paths also need to be added to their names.
          Try toolbar.show to 'show' the toolbar - works for me... πŸ˜‰

          TIG

          1 Reply Last reply Reply Quote 0
          • P Offline
            Pout
            last edited by

            "crawls in a corner in shame"

            Thx! sometimes I can just hit myself

            1 Reply Last reply Reply Quote 0
            • Dan RathbunD Offline
              Dan Rathbun
              last edited by

              @pout said:

              Am I correct? Is it not possible to create a toolbar, from in the ruby console, using these commands?

              The danger is that the console is running inside Object, and you are using local variables (cmd and toolbar.) Any other 'unwrapped' script that afterward uses the same variable names, will make those 'symbols' point to other UI::Command and UI::Toolbar objects, and you will lose access to them. (Ruby will still know what they are, and the command and toolbar should still work. But you will not be able to make any changes, such as changing the tooltip text.)

              IF that's OK, or your just testing, no harm. But if you want later access to your command or toolbar objects, you will need to keep them in unique variable identifiers. For example, you could store them in a Hash.
              MyToolbars={'FancyCommand' => cmd, 'PoutTools' => toolbar }
              Then later on:
              MyToolbars['FancyCommand'].tooltip="Select object before doing something Fancy!"

              See this post for more info:
              http://forums.sketchucation.com/viewtopic.php?f=180&t=15621&p=220266#p219128

              I'm not here much anymore.

              1 Reply Last reply Reply Quote 0

              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 Login
              • 1 / 1
              • First post
                Last post
              Buy SketchPlus
              Buy SUbD
              Buy WrapR
              Buy eBook
              Buy Modelur
              Buy Vertex Tools
              Buy SketchCuisine
              Buy FormFonts

              Advertisement