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

    Create toolbar on the fly

    Scheduled Pinned Locked Moved Developers' Forum
    5 Posts 4 Posters 252 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
              • 1 / 1
              • First post
                Last post
              Buy SketchPlus
              Buy SUbD
              Buy WrapR
              Buy eBook
              Buy Modelur
              Buy Vertex Tools
              Buy SketchCuisine
              Buy FormFonts

              Advertisement