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

Suggestion for code - Minimize (rollup) Outliner

Scheduled Pinned Locked Moved Developers' Forum
11 Posts 7 Posters 2.3k 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.
  • J Offline
    JClements
    last edited by 16 Jan 2009, 05:04

    If you run an intensive script in a model with lots of groups and components and have the Outliner open and maximized (rolled down), then things can come to grinding halt (or nearly a grinding halt).

    Could a block of code developed which could be used in new or existing scripts or called from within a script which would do the following????:

    1- Check to see if the Outliner is open and maximized (rolled down). If so, Roll it up or close it.
    2- Then execute the intended script.
    3- When the intended script is finished, the Outliner is Rolled down or re-opened ... to whatever state it was prior to running the intended script.

    John

    John | Illustrator | Beaverton, Oregon

    1 Reply Last reply Reply Quote 0
    • J Offline
      Jim
      last edited by 17 Jan 2009, 02:01

      That's a good suggestion, John.

      I tried a quick experiment. It is possible to shade the Outliner from Ruby, but I don't see a way to tell if it is currently open. Anyone have an idea about that?

      Note that the Ruby API in SketchUp 7 has changed to address this issue. The change is in the start_operation method:

      SU 6:

      
      Sketchup.active_model.start_operation("Create a zillion faces")
      
      

      versus SU 7:

      
      Sketchup.active_model.start_operation("Create a zillion faces", true)
      
      

      Hi

      1 Reply Last reply Reply Quote 0
      • C Offline
        CPhillips
        last edited by 18 Jan 2009, 05:21

        I wrote this up a while ago. I am pretty sure I sent it to you Jim...

        def toggleRollUp(name)
            findWindow = Win32API.new("user32.dll", "FindWindow", ['P','P'], 'N')
            pw=findWindow.call(0,name)
           
            sendMessage = Win32API.new("user32.dll", "SendMessage", ['N','N','N','P'], 'N')
           
            sendMessage.call (pw,0x00a1,2,"")#WM_NCLBUTTONDOWN
            sendMessage.call(pw,0x0202,0,"")#WM_LBUTTONUP
        end
        def isRolledUp(name)
            findWindow = Win32API.new("user32.dll", "FindWindow", ['P','P'], 'N')
            getWindowRect= Win32API.new("user32.dll", "GetWindowRect",['P','PP'], 'N')
            pw=findWindow.call(0,name) 
        
            data=Array.new.fill(0.chr,0..4*4).join
            getWindowRect.call (pw,data);
            rect=data.unpack("i*")
                #if window height is less than 90 then the window is rolledup
            return (rect[3]-rect[1])<90
        end
        
        1 Reply Last reply Reply Quote 0
        • K Offline
          kwistenbiebel
          last edited by 18 Jan 2009, 08:25

          Wow, this is an excellent idea.

          The outliner is a fantastic tool when editing.
          But it is indeed a pain in the ass when you got it open while using heavy scripts.

          This (future) script might save me a headache 😄

          1 Reply Last reply Reply Quote 0
          • J Offline
            Jim
            last edited by 18 Jan 2009, 18:06

            You would still need to add it every existing script you want to use it in.

            Hi

            1 Reply Last reply Reply Quote 0
            • J Offline
              JClements
              last edited by 18 Jan 2009, 21:36

              Jim F:

              So if CPhillips' code can be stored as a .rb and is given a name like "Outliner_Rollup.rb" and it is located in the SU/Plugins directory, what code would need to be inserted into a script to call Outliner_Rollup.rb and where should it be placed relative to the existing code?

              John

              John | Illustrator | Beaverton, Oregon

              1 Reply Last reply Reply Quote 0
              • C Offline
                CPhillips
                last edited by 19 Jan 2009, 01:14

                @jclements said:

                Jim F:

                So if CPhillips' code can be stored as a .rb and is given a name like "Outliner_Rollup.rb" and it is located in the SU/Plugins directory, what code would need to be inserted into a script to call Outliner_Rollup.rb and where should it be placed relative to the existing code?

                John

                I added hideOutliner() and restoreOutliner(). Just call before and after your script respectively.

                
                require "win32api.so"
                #these 2 functions are untested but should work.
                def hideOutliner()
                   $bOutlinerWasOpen=!isRolledUp("Outliner")
                   toggleRollUp("Outliner") if $bOutlinerWasOpen
                end
                def restoreOutliner()
                   toggleRollUp("Outliner") if $bOutlinerWasOpen
                end
                
                def toggleRollUp(name)
                    findWindow = Win32API.new("user32.dll", "FindWindow", ['P','P'], 'N')
                    pw=findWindow.call(0,name)
                   
                    sendMessage = Win32API.new("user32.dll", "SendMessage", ['N','N','N','P'], 'N')
                   
                    sendMessage.call (pw,0x00a1,2,"")#WM_NCLBUTTONDOWN
                    sendMessage.call(pw,0x0202,0,"")#WM_LBUTTONUP
                end
                def isRolledUp(name)
                    findWindow = Win32API.new("user32.dll", "FindWindow", ['P','P'], 'N')
                    getWindowRect= Win32API.new("user32.dll", "GetWindowRect",['P','PP'], 'N')
                    pw=findWindow.call(0,name)
                
                    data=Array.new.fill(0.chr,0..4*4).join
                    getWindowRect.call (pw,data);
                    rect=data.unpack("i*")
                        #if window height is less than 90 then the window is rolledup
                    return (rect[3]-rect[1])<90
                end
                
                
                1 Reply Last reply Reply Quote 0
                • A Offline
                  avariant
                  last edited by 19 Jan 2009, 18:06

                  While you'll still need a method to determine if the Outliner is visible or not... you can just call this:

                  UI.show_inspector "Outliner"
                  

                  to toggle between rolled up and rolled down. (At least in SU 7, didn't try 6)

                  1 Reply Last reply Reply Quote 0
                  • A Offline
                    alz
                    last edited by 21 Jan 2009, 14:47

                    Had a similar problem awhile back and just hacked it by adding "Sketchup.send_action 21926" before/after the function to temporarily hide all the dialog windows.

                    The above ideas are more elegant and official, however

                    --alz

                    1 Reply Last reply Reply Quote 0
                    • J Offline
                      Jim
                      last edited by 22 Dec 2014, 20:59

                      Is this still valid for Ruby 2, or is there now a better way using the Ruby StdLib?

                      Hi

                      1 Reply Last reply Reply Quote 0
                      • J Offline
                        johnzdennis
                        last edited by 20 Oct 2016, 22:38

                        I see this thread is almost ten years old, but has this issue ever actually gotten fixed?

                        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