Opening a custom-made directory with the components browser
-
hey guys,
I'm using this to open the component browser:
UI.show_inspector "Components"
However, I want to open a custom folder that I have made within the the components directory. Does anyone know how to direct the components browser to open that specific folder to browse through?
Here is the path of the folder I'm trying to browse:
C:\Program Files\Google\Google SketchUp 7\Components\custom_folder
Thanks!
-
Hi Justin,
I'll definitely not going to be the one who can answer but if you wish, I can move the topic to the Ruby dept. for better attention by those who could help.
-
@ruski_canuk said:
I'm using this to open the component browser:
UI.show_inspector "Components"
However, I want to open a custom folder that I have made within the the components directory. Does anyone know how to direct the components browser to open that specific folder to browse through?
Here is the path of the folder I'm trying to browse:
C:\Program Files\Google\Google SketchUp 7\Components\custom_folderYou need to change the registry values [for PC]
HKEY_CURRENT_USER\Software\Google\SketchUp6\File Locations >>> key ComponentBrowser1 REG_SZ value >>> C:\Program Files\Google\Google SketchUp 7\Components\custom_folder
You could try to do it this way:folder="C;\\Program Files\\Google\\Google SketchUp 7\\Components\\custom_folder\\" Sketchup.write_default("File Locations","ComponentBrowser1",folder)
Notes: the correct method is 'write_default' as v7 API and NOT 'write_defaults' or 'write_defults' as the v6 API incorrectly says ! Also the folder separators \ have been 'escaped' with \ otherwise you'll get error messages - I also added an ending \ though it's not strictly necessary as the system adds it anyway...
So this sounds good so far... Sorry, but it's NOT !
After you run this code the registry entry does indeed change to match the folder path given - however, you need the folder path to be inside '..' or ".." to make the SUp method work and these are added to the registry value too which then makes it un-readable by the system, so it's ignored, BUT in any case [even if you did manage to hack the right value into the registry key] SUp has already read the initial registry values when it started, so it opens the Components Browser using those - giving the folder that was open when SUp was last closed. Running the code doesn't change the value that's now in memory. Worse is to come - unless you change the folder manually, when you close SUp it remembers the current folder as that registry entry for use next time - undoing your code-driven / hacked changes. This means you can't even try to re-write the registry, save the model, close to model and reopen the model, as the close will simply re-make or remember the old the registry settings and use those on the re-open...The only use of SUp's read/write registry value tools is to save/update data that isn't automatically overwritten by SUp on open/close - like web-dialog details etc...
Sorry! I can't see how you can do it ? Any other suggestions ???
-
Gaieus - Please do move this to the Ruby thread, I didn't mean to post here, I think I saw "Sketchup" which, combined with the late hour, must have sent me into a state of overly reactive decision making and I posted...
TIG - I get the feeling that you have tried this before Would there be any way to use an observer on exit which over-writes the reg entry? I guess it depends if the observer fires before or after whatever Sketchup is automatically firing on the open/close.
best,
Justin@tig said:
@ruski_canuk said:
I'm using this to open the component browser:
UI.show_inspector "Components"
However, I want to open a custom folder that I have made within the the components directory. Does anyone know how to direct the components browser to open that specific folder to browse through?
Here is the path of the folder I'm trying to browse:
C:\Program Files\Google\Google SketchUp 7\Components\custom_folderYou need to change the registry values [for PC]
HKEY_CURRENT_USER\Software\Google\SketchUp6\File Locations >>> key ComponentBrowser1 REG_SZ value >>> C:\Program Files\Google\Google SketchUp 7\Components\custom_folder
You could try to do it this way:folder="C;\\Program Files\\Google\\Google SketchUp 7\\Components\\custom_folder\\" > Sketchup.write_default("File Locations","ComponentBrowser1",folder)
Notes: the correct method is 'write_default' as v7 API and NOT 'write_defaults' or 'write_defults' as the v6 API incorrectly says ! Also the folder separators \ have been 'escaped' with \ otherwise you'll get error messages - I also added an ending \ though it's not strictly necessary as the system adds it anyway...
So this sounds good so far... Sorry, but it's NOT !
After you run this code the registry entry does indeed change to match the folder path given - however, you need the folder path to be inside '..' or ".." to make the SUp method work and these are added to the registry value too which then makes it un-readable by the system, so it's ignored, BUT in any case [even if you did manage to hack the right value into the registry key] SUp has already read the initial registry values when it started, so it opens the Components Browser using those - giving the folder that was open when SUp was last closed. Running the code doesn't change the value that's now in memory. Worse is to come - unless you change the folder manually, when you close SUp it remembers the current folder as that registry entry for use next time - undoing your code-driven / hacked changes. This means you can't even try to re-write the registry, save the model, close to model and reopen the model, as the close will simply re-make or remember the old the registry settings and use those on the re-open...The only use of SUp's read/write registry value tools is to save/update data that isn't automatically overwritten by SUp on open/close - like web-dialog details etc...
Sorry! I can't see how you can do it ? Any other suggestions ???
-
Okay, I am moving it (I didn't mean it was in a WRONG place just the other one could be better )
-
Also in passing - I note that a new method UI.refresh_inspectors is added to v7 API - however this doesn't seem to do what you'd expect either ? The Components Browser seems unchanged when you have manually changed the corresponding registry value during a session and then run this... This method is of course useless anyway if we can't get the registry value to have NO enclosing "" !!!
Also I note that UI.show_panel("Components") opens/rolls-up/-down the browser window. Unfortunately there seems no way to see if it's open first or rolled-up/-down - it just opens it if it's not open, or if it is open then it toggles between rolled-up/-down - with no control of how it'll end up being - hence the hacky PC only fix is used [Jim's ideas] to roll-up the Outliner Window if it's open, it's used to avoid bugsplats in my recent ComponentInstance-add_entities.rb...
...
-
Justin
Are you on a PC ? If so I perhaps know how to make it 'windows scripted' [but only 'perhaps'...]...
-
TIG-
I am on a PC though trying to do a similar thing for the mac. I'll try some observer fun but am sure to be splatted into oblivion Thanks for your thoughts.
best,
Justin
Advertisement