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

    Float toolbar on creation?

    Scheduled Pinned Locked Moved Developers' Forum
    45 Posts 7 Posters 1.2k Views 7 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.
    • thomthomT Offline
      thomthom
      last edited by

      hmm...

      n = UI::Toolbar.new('FooBar') #<UI::Toolbar:0xd0820a8> n.add_item(c) #<UI::Toolbar:0xd0820a8> n.add_item(c) #<UI::Toolbar:0xd0820a8> n.add_separator #<UI::Toolbar:0xd0820a8> n.add_item(c) #<UI::Toolbar:0xd0820a8> n.show nil n.add_separator #<UI::Toolbar:0xd0820a8> n.add_item(c) #<UI::Toolbar:0xd0820a8>
      Even when I have the original toolbar object I can't add items after the toolbar has been shown. The last two items in the above sample where not added to the toolbar. Is it really not possible to add items dynamically afterwards?

      Thomas Thomassen — SketchUp Monkey & Coding addict
      List of my plugins and link to the CookieWare fund

      1 Reply Last reply Reply Quote 0
      • thomthomT Offline
        thomthom
        last edited by

        @tig said:

        The entry ToolbarsUser-Summary > Bars gives the total number of 'user toolbars' so you can construct a loop to go through to find each one with NN ...

        Sketchup.read_default('ToolbarsUser-Summary', 'Bars', nil)
        This just returns 1 for me. The registry value is 49.

        Thomas Thomassen — SketchUp Monkey & Coding addict
        List of my plugins and link to the CookieWare fund

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

          It should return that value BUT I don't even get 1 - I get nil ???

          TIG

          1 Reply Last reply Reply Quote 0
          • thomthomT Offline
            thomthom
            last edited by

            I wonder if Sketchup.read_default prevents access to SU's own registry values. Might have to use the Win32 API - or have anyone been able to access any of the other SU registry values?

            I can only get S ketchup.read_default to return correct values for what Sketchup.write_default has created. 😕 thought this could be an easy cross platform method for SU settings... 😞

            Thomas Thomassen — SketchUp Monkey & Coding addict
            List of my plugins and link to the CookieWare fund

            1 Reply Last reply Reply Quote 0
            • thomthomT Offline
              thomthom
              last edited by

              Doing some tests:

              
              require 'C;/Ruby/lib/ruby/1.8/win32/registry.rb'
              
              
              module TT_Test
                
                def self.toolbars
                  toolbars = []
                  begin
                    path_summary = 'Software\\Google\\SketchUp7\\ToolbarsUser-Summary'
                    Win32;;Registry;;HKEY_CURRENT_USER.open(path_summary) { |reg|
                      bars = reg.read_i('Bars')
                      
                      (0..bars-1).each { |i|
                        section = "ToolbarsUser-Bar#{i}"
                        begin
                          path_toolbar = "Software\\Google\\SketchUp7\\#{section}"
                          Win32;;Registry;;HKEY_CURRENT_USER.open(path_toolbar) { |r|
                            r.each { |subkey, type, data|
                              if type == Win32;;Registry;;REG_SZ && subkey == 'BarName'
                                toolbars << data
                                break
                              end
                            }
                          }
                        rescue
                          next
                        end
                      }
                    }
                    return toolbars
                  rescue
                    return nil
                  end
              
                end # def
              
              end
              
              

              Gets an array of Ruby Toolbars. Work on PC - but requires registry.rb. Will look into calling the Win32 API directly so it only requires Win32API.

              (I'm not sure how to deal with requirements of standard ruby libraries. include the registry.rb with my plugin and load only if it isn't defined? require 'C:\ruby\lib\ruby\1.8\win32\registry.rb' if defined?(Win32::Registry).nil?)

              How do you read settings on OSX? Where are these settings stored?

              Thomas Thomassen — SketchUp Monkey & Coding addict
              List of my plugins and link to the CookieWare fund

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

                The Mac has 'plist' files like an 'ini' file == the registry...

                TIG

                1 Reply Last reply Reply Quote 0
                • thomthomT Offline
                  thomthom
                  last edited by

                  Does OSX have an API to read it, or do you just open it and parse it yourself?

                  Thomas Thomassen — SketchUp Monkey & Coding addict
                  List of my plugins and link to the CookieWare fund

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

                    I am Macless. I don't know about plist API readers ...
                    Here is a 'plist' set someone gave me for info - it is 'readable' - just about...MacPlistArchive.zip
                    Here's another useful link http://developer.apple.com/documentation/MacOSX/Conceptual/BPRuntimeConfig/Articles/ConfigFiles.html

                    TIG

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

                      There are plist editors available that make the task much simpler by parsing it for you and showing what can be changed etc. eg http://www.macupdate.com/info.php/id/14363

                      Chris

                      1 Reply Last reply Reply Quote 0
                      • thomthomT Offline
                        thomthom
                        last edited by

                        I'll check that out. I got an old Mac mini to test on.

                        Thomas Thomassen — SketchUp Monkey & Coding addict
                        List of my plugins and link to the CookieWare fund

                        1 Reply Last reply Reply Quote 0
                        • thomthomT Offline
                          thomthom
                          last edited by

                          hmm... the Info.plist file in the Sketchup application package does not contain the same info we see in the Windows registry...

                          Thomas Thomassen — SketchUp Monkey & Coding addict
                          List of my plugins and link to the CookieWare fund

                          1 Reply Last reply Reply Quote 0
                          • J Offline
                            Jim
                            last edited by

                            I can't seem to get a handle on the Large Tool Set to hide it, any ideas?

                            i.e. these don't work:

                            UI.set_toolbar_visible("Large Tool Set", false) UI.set_toolbar_visible("LargeToolSet", false)

                            Hi

                            1 Reply Last reply Reply Quote 0
                            • thomthomT Offline
                              thomthom
                              last edited by

                              @jim said:

                              I can't seem to get a handle on the Large Tool Set to hide it, any ideas?

                              i.e. these don't work:

                              UI.set_toolbar_visible("Large Tool Set", false) UI.set_toolbar_visible("LargeToolSet", false)

                              Yea - it's untouchable.

                              UI.toolbar_names
                              ["Standard", "Principle", "Camera", "Drawing", "Edit", "Construction", "Walk", "DisplayMode", "StandardViews", "Section", "Google", "GettingStarted", "VCB"]
                              That's the only ones we can get. And this is on PC. On Mac it's two completely different names.

                              Thomas Thomassen — SketchUp Monkey & Coding addict
                              List of my plugins and link to the CookieWare fund

                              1 Reply Last reply Reply Quote 0
                              • thomthomT Offline
                                thomthom
                                last edited by

                                I've managed to get a list of Ruby created toolbars on PC.

                                But on Mac I got some problems.
                                I found a plist at /Users/<user>/Library/Preferences/

                                One com.google.sketchupfree.plist and one com.google.sketchupfree7.plist

                                What I'm not sure how to is:

                                1. find the current user so I know the path to the plist
                                2. the name of the plist - which I think is related to the application id. http://developer.apple.com/mac/library/documentation/MacOSX/Conceptual/BPRuntimeConfig/Articles/UserPreferences.html#//apple_ref/doc/uid/20002092 Need a way to get the application’s bundle identifier for the Sketchup version the script is running in.
                                3. the toolbar names I get from these files doesn't seem to be 100% complete. think they might only appear if they've been shown at some point.

                                Thomas Thomassen — SketchUp Monkey & Coding addict
                                List of my plugins and link to the CookieWare fund

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

                                  @thomthom said:

                                  I've managed to get a list of Ruby created toolbars on PC.

                                  But on Mac I got some problems.
                                  I found a plist at /Users/<user>/Library/Preferences/

                                  One com.google.sketchupfree.plist and one com.google.sketchupfree7.plist

                                  What I'm not sure how to is:

                                  1. find the current user so I know the path to the plist
                                  2. the name of the plist - which I think is related to the application id. http://developer.apple.com/mac/library/documentation/MacOSX/Conceptual/BPRuntimeConfig/Articles/UserPreferences.html#//apple_ref/doc/uid/20002092 Need a way to get the application’s bundle identifier for the Sketchup version the script is running in.
                                  3. the toolbar names I get from these files doesn't seem to be 100% complete. think they might only appear if they've been shown at some point.

                                  I suspect the com.google.sketchupfree7.plist refers to a later install and that you can delete the other (maybe from a SU6 install?) without problems - just rename it temporarily and try .

                                  I only have com.google.sketchuppro7.plist; com.google.sketchuppro7.LSSharedFileList.plist; com.google.LayOut.plist; com.google.LayOut.LSSharedFileList.plist; com.google.style_builder.plist

                                  All clearly related to my SU 7 pro installation

                                  Chris

                                  1 Reply Last reply Reply Quote 0
                                  • wind-borneW Offline
                                    wind-borne
                                    last edited by

                                    :

                                    "To read between the lines was easier than to follow the text."OSX 10.11.6

                                    %(#BF80BF)[SU 8 pro

                                    1 Reply Last reply Reply Quote 0
                                    • thomthomT Offline
                                      thomthom
                                      last edited by

                                      @chrisjk said:

                                      I suspect the com.google.sketchupfree7.plist refers to a later install and that you can delete the other (maybe from a SU6 install?) without problems - just rename it temporarily and try .

                                      Yes - I have SU6 and SU7 installed.

                                      The thing is - I need a way to determine the filename of the preference file for the Sketchup version the script is running under.

                                      From this link: http://developer.apple.com/mac/library/documentation/MacOSX/Conceptual/BPRuntimeConfig/Articles/UserPreferences.html#//apple_ref/doc/uid/20002092

                                      @unknownuser said:

                                      The name of each file in Library/Preferences is comprised of the application’s bundle identifier followed by the .plist extension. For example, the bundle identifier for the TextEdit application is com.apple.TextEdit so its preferences file name is com.apple.TextEdit.plist.

                                      But I have no idea of how to obtain the bundle identifier...

                                      Thomas Thomassen — SketchUp Monkey & Coding addict
                                      List of my plugins and link to the CookieWare fund

                                      1 Reply Last reply Reply Quote 0
                                      • thomthomT Offline
                                        thomthom
                                        last edited by

                                        Found the username in the ENV array. Still need to get the bundle ID.

                                        Thomas Thomassen — SketchUp Monkey & Coding addict
                                        List of my plugins and link to the CookieWare fund

                                        1 Reply Last reply Reply Quote 0
                                        • thomthomT Offline
                                          thomthom
                                          last edited by

                                          Ok - made some progress. Got code working on both Windows and OSX 10.4 (SU7.1). Other systems and versions untested.

                                          Note that there are still issues. This code needs to be tested more.

                                          • On Windows it require registry.rb and Win32API from a normal ruby installation. Not sure how to bundle this - in terms of license and general practicability.
                                          • On OSX it appears that toolbar names only appears in the plist if it has previously been shown at some point. If it hasn't then there isn't any trace of it. Looking for other source for the names.
                                          • I'm not familiar with how to get OSX data - so it's a bit of hacky brute force approach. Might be a better method to get the data. Certainly needs testing.

                                          Work In Progress

                                          Thomas Thomassen — SketchUp Monkey & Coding addict
                                          List of my plugins and link to the CookieWare fund

                                          1 Reply Last reply Reply Quote 0
                                          • thomthomT Offline
                                            thomthom
                                            last edited by

                                            The Win version will list old toolbar names - toolbars that are no longer present, but still got remains in the registry.

                                            Was thinking of running a loop testing against UI.toolbar - but it will create a new toolbar if given the name of a non-existent toolbar. Acts like UI::Toolbar.new.

                                            Thomas Thomassen — SketchUp Monkey & Coding addict
                                            List of my plugins and link to the CookieWare fund

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

                                            Advertisement