sketchucation logo sketchucation
    • Login
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Toolbar conversion

    Scheduled Pinned Locked Moved Developers' Forum
    7 Posts 3 Posters 239 Views 3 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.
    • jojo9J Offline
      jojo9
      last edited by

      Hi,

      last night i converted some useful rubies without toolbar support, to use instead toolbar buttons.
      Such buttons are always smarter as to dig through menus, even if your ruby depot isn't too big, especially when you have to reuse some commands over and over again. I say only: annoying…Not that i'm good in ruby coding, but i managed it smartly with common sense and some code snippets.
      What i need are yet two simple commands, to add to my toolbar list :

      -to open the -model info- window, preferable positioned in the middle of the screen
      -to convert a selection in a group
      -a hint how to add hard-coded rubies (ending with 'unpack') to a toolbar

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

        1-to open the -model info- window, preferable positioned in the middle of the screen
        {UI.show_model_info('')}

        2-to convert a selection in a group
        {Sketchup.active_model.active_entities.add_group(Sketchup.active_model.selection.to_a)if Sketchup.active_model.selection[0]}

        3-a hint how to add hard-coded rubies (ending with 'unpack') to a toolbar
        The obfuscation is because the author wants to prevent you from easily seeing his code.
        As you realize, it is 'packed', and its 'unpack' function undoes that back into plain text, and then uses 'eval' on that, so as to turn the lines of text into the needed lines of code...
        With a little though you could work out how to change it around - e.g. rather that passing the 'unpacked' text to 'eval' use 'puts' on it so you can see it in the Ruby Console... Then you can work out how it calls its menu items etc... simply replicate these in your own {...}
        🤓

        TIG

        1 Reply Last reply Reply Quote 0
        • jojo9J Offline
          jojo9
          last edited by

          Hi TIG
          everything worked fine for me, for all of the three points. The model info window needed yet ('') to work.
          UI.show_model_info ('')

          a last question:
          how do i to start Su with my toolbars already visible ?
          i used to start my toolbars from a 'launcher ruby' (toolbar rubies are stored in a extra directory inside the Plugins folder) and added this lines:

          tb4= UI;;Toolbar.new("Toolbar")
           tb4.show
           tb4.restore if tb4.get_last_state==TB_VISIBLE
          #ect.
          

          but… it isn't the best solution: because it creates a new Toolbar instance, even when no rubies are attached to it. This means i get an empty button without functionality.

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

            Yes:
            UI.show_model_info('') opens it on the last opened pane
            UI.show_model_info('units') opens it on the units pane etc...
            Sorry if I didn't explain that clearly...

            You must make you toolbar reference 'enduring'...
            Inside a module 'wrapper' try ' @toolbar=' or even set a constant ' TOOLBAR='...
            this needs to be in an early loading .rb script, so prefix it with say '!'...
            Then you can add entires to that reference to the toolbar from other loading scripts as SketchUp starts/loads...
            Avoid 'global' variables unless they are exceptionally uniquely named - otherwise other scripts might clash... [ $jojo9_toolbar=]
            You can't change a toolbar later on after it's been loaded.

            TIG

            1 Reply Last reply Reply Quote 0
            • D Offline
              driven
              last edited by

              @jojo9 said:

              a last question:
              how do i to start Su with my toolbars already visible ?

              you should fill in your profile so Tig and others know your on a mac...

              also are you still on v8?

              with v2013, on some mac's toolbars don't show on startup, unless they use .show, it's really annoying.

              I have a plugin that lets you arrange your favourite toolbars, and it makes a list of them, after startup you can go to the help menu and click 'show my toolbars' and they all reappear at once.

              I will add a button for it at some point but if you want a play let me know and I'll PM you a copy.

              john

              learn from the mistakes of others, you may not live long enough to make them all yourself...

              1 Reply Last reply Reply Quote 0
              • jojo9J Offline
                jojo9
                last edited by

                Hi john
                and thanks. I fear i cannot get your zip file anymore, because i can't see any more users attachments since Sketchucation was restyled/updated.

                1 Reply Last reply Reply Quote 0
                • D Offline
                  driven
                  last edited by

                  I sent it in a PM as a 'code block', just copy paste, no zip...

                  john

                  learn from the mistakes of others, you may not live long enough to make them all yourself...

                  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