Shuffle-ruby script?
-
I think you ought to be able to do the random part of this using the Proximity Components part of Matrix Proximity. Putting the three different colored containers into the Proximity Containers folder should trigger an option to randomise.
@unknownuser said:
The matrix copied component might belong to a Proximity Component ‘family’ (one of the trio-sets – typically the ‘Far’ type – see later). If so then Matrix realises this and looks for related family components of the same type (e.g. Far) that are already made within or loaded into the model or are in the Proximity Components folder. If it finds them a dialog tells you how many alternatives are available for use and asks if you want to swap and
randomly scatter them within the matrix copies (this is in approximately equal proportions). This is useful for introducing randomness and naturalness into groups of trees etc – use a Proximity Component family ‘Far’ tree to make the matrix initially (e.g. tree-001-) and if you have say three others available tree-002-, tree-003- and tree-004- then the result would be a randomized mix of the four types.I also wondered if a fourth container with zero height - a flat plane might let the others drop - I don't think so, but perhaps if you turned Sketchy Physic on . . .
Unfortunately I cant test as I get an error message with the version of Matrix Proximity I downloaded
@unknownuser said:"Error: #<Errno::ENOENT: No such file or directory - F:/PROGRA~1/Google/GOOGLE~2Components\Proximity Components>"
- there's a slash missing and I can't see how to fix it
Bob
-
With a little de-bugging and a lot of trial and error the MatrixProximity shuffle works nicely.
Create a 'Components/Proximity Components' folder and save copies of unique components into it. Mine were named 'container-001-.skp' 'container-002-.skp' & 'container-003-.skp'
Create a new SketchUp drawing with only one container in it (the shuffle will not work if the proxy containers are already in the drawing).
Create your stack and, if all is well, you will see a second dialogue asking you if you want to Merge copies of the other components. Say Yes.
I had to make a couple of small changes to the script to get round the Error message below. If you need them I'll post them here.
Bob
PS Creating 'zero-height' containers and adding them to the mix worked well. Using Sketchy Physics to drop the columns was a spectacular disaster . . .
-
Thank you for the help. I am still having some problems. I never get the dialog that asks to merge copies.
I have Proximity Components folder in this path (C:\Program Files\Google\Google SketchUp 6\Components\Proximity Components) and I have named containers (cont-001-,cont-002-,cont-003-,cont-004-). I have taken the cont-001- and placed it in the drawing => run the Matrix => I get multible copies => I get dialog that asks if I want to drop the componets onto nearest faces => but after that I never get any dialog to asks to merge copies. I have tried this same workflow with components that were alrady in the Proximity Components folder but still it does not ask to merge copies.
Do you have any idea what could be the problem?
-
The problem that I found was that the script wasn't able to open the sub-folder. When I open the RubyScript console I saw an error at line 415 (or thereabouts).
There is a line that reads something like:
proxdir = (Sketchup.find_support_file "", "Components/Proximity Components/") + "Components//Proximity Components//"
I replaced this with two lines:
proxdir_1 = Sketchup.find_support_file "", "Components/Proximity Components/" proxdir = proxdir_1 + "/Components/Proximity Components/"
Bob
-
Thank you for helping me. Now it works perfect.
-
Couldn't resist it. Here's a hacked version of the script that adds a 'Density' value to the dialogue box. The image below is at 85% which is the default (change this at line 234 to your preference).
Bob
Back up the original version and copy this to PlugIns folder.
-
Thanks for saving me some work Greyhead! (from one soon to be grey head to another!)
-
Thanks GreyHead for the error report*. It's over 2 years since the MatrixProximity code was last looked at by me !
Here's the 'official' Update v1.7 - http://www.sketchucation.com/forums/scf/viewtopic.php?p=46802#p46802
Note that GreyHead's changed version two posts below has some menu problems in it...
You might want to hack out his "density" bits if they are useful and add them back in ?
This fixes those AND the error* problem, with it finding the right directory - caused by changes to the way Ruby 'now' returns the FindFile path with/without a / at the end of a directory... [actually it changed ages ago, but I never caught it...]
Sorry for the slow response...
-
Thanks TIG - the density bit was very much a hack. More a learning experiment than serious coding. (Though I was quite impressed with myself that I got it to work at all!)
I forgot that I'd commented out the menu entries - is there a way of editing and rerunning a script that's loaded into a menu without re-starting Sketchup?
Bob
-
@greyhead said:
Thanks TIG - the density bit was very much a hack. More a learning experiment than serious coding. (Though I was quite impressed with myself that I got it to work at all!)
I forgot that I'd commented out the menu entries - is there a way of editing and rerunning a script that's loaded into a menu without re-starting Sketchup?
Bob
Easy: type, 'load "script_name.rb"', into the Ruby console - it will reload the script completely. You need the 'load menu if script not loaded' test bits at the end - or else you'll get multiple menu entries - even then the latest menu entry's on the end ! - but most scripters add that test in anyway...
All /Plugins/ .rb files load automatically at startup, but you can also load any .rb files that have a .txt suffix at any time by using the, 'load "file.txt"' method - that's useful for rarely used scripts that you wouldn't want cluttering things up all the time...
.
IF the 'density' bit is thought useful I could add it into the 'official' version... Comments please...
-
@TIG: I'd rather use randomselect in this case
-
For my purpose/need this density function is just perfect. Thanks again GreyHead! But right now I can't think any other way to benefit from this function when using MatrixProximity script. I will be fine with this unofficial version.
Advertisement