Suggestion for code - Minimize (rollup) Outliner
-
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
-
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)
-
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
-
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
-
You would still need to add it every existing script you want to use it in.
-
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
-
@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
-
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)
-
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
-
Is this still valid for Ruby 2, or is there now a better way using the Ruby StdLib?
-
I see this thread is almost ten years old, but has this issue ever actually gotten fixed?
Advertisement