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

    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.
    • JClementsJ Offline
      JClements
      last edited by

      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

        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

          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

            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

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

              Hi

              1 Reply Last reply Reply Quote 0
              • JClementsJ Offline
                JClements
                last edited by

                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

                  @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

                    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

                      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

                        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

                          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