First script is just for make some random selection!
Not for move something! ;)
It works like this : Draw some many things
Select all
Call the plugin = you have a random selection following your % asked!
Here i use the Transform / Array / Dir for populate the screen
For the second one You must have yet some Styles existing!
script: /* Random Color to something on the screen */ var styles = moi.geometryDatabase.getObjectStyles(); var breps = moi.geometryDatabase.getObjects().getBReps(); for ( var i = 0; i < breps.length; ++i ) { var brep = breps.item(i); var edges = brep.getEdges(); for ( var j = 0; j < edges.length; ++j ) { edges.item(j).styleIndex = Math.floor(Math.random() * styles.length); } var faces = brep.getFaces(); for ( var j = 0; j < faces.length; ++j ) { faces.item(j).styleIndex = Math.floor(Math.random() * styles.length); } }
Hi Don, I don't know of a good method for doing the random placement in MoI since it would need to consider collision detection between the objects.
I'd probably try something that has a physics simulation in it, then you could drop them into the container and they should settle in. Maybe Blender: https://youtu.be/KtjJfWlQ8
Thanks, but I really can't see how that will help me achieve what I asked for, since the array tools can't or doesn't seem to offer the random placement as I asked for in a specified area. Your first script is only selecting a percentage of what is there and that is all. I can select one or more simply by selecting them with left mouse clicks to get the same result.
Thanks Christian. I don't know Sketchup at all so I would need to spend time learning it first and might consider that.
I did ask on a couple other forums and it looks like it can be done quite easily in SolidWorks with a basic motion study. I have access to that, so I will try in there first. The attached is from the SW forum.
Perhaps could you see this page github.com/schteppe/cannon.js
You could find a simple 3D physics engine for js with many samples like spheres falling.
During simulation, you could have the coords of spheres fallen.
I you find a script taking coords to place your spheres in MOI3D.
An idea perhaps to help you...
This idea could be used to place objects physically or narturally ?
If you want a complet tuto about MS Physics (for SketchUP) take a look at this ;)
26 little videos :) ps Sketchup is 10 times more easy than Blender! :)
Populate your volume with Tangent cubes ...it's not a big deal!
Then draw a sphere at each center box!
script: /* Attribute a point at each center box's object selected*/ var objs = moi.geometryDatabase.getSelectedObjects(); for ( var i = 0; i < objs.length; ++i ) { var obj = objs.item(i); var pt = obj.getBoundingBox().center; var ptfactory = moi.command.createFactory( 'point' ); ptfactory.setInput( 0, pt ); ptfactory.commit(); }
So copy the 2 files inside the folder commands
and make a shortcut "copytopoints" or press Tab and write Copytopoints...or COpyToPoints etc...
any letters you want except spaces
Damned seems there is a SyntaxError: Expected token ')' somewhere in this
???
script: /* Attribute a point at each center box's object selected*/ var objs = moi.geometryDatabase.getSelectedObjects(); for ( var i = 0; i < objs.length; ++i ) { var obj = objs.item(i); var pt = obj.getBoundingBox().center; var ptfactory = moi.command.createFactory( 'point' ); ptfactory.setInput( 0, pt ); ptfactory.commit(); }
this is the good one!!! (don't know where is the difference but... :)
script: /* Place a point at each selected object's bounding center */ var objs = moi.geometryDatabase.getSelectedObjects(); for ( var i = 0; i < objs.length; ++i ) { var obj = objs.item(i); var pt = obj.getBoundingBox().center; var ptfactory = moi.command.createFactory( 'point' ); ptfactory.setInput( 0, pt ); ptfactory.commit(); }
You can also draw 2 Circles (constant radius) in a view
then now same radius circle but now Tangent !
Copy rotate at any moment in another view!for the third and upper...
At the end no problem to remplace all by spheres with the plugins seen above!
Like this you can simulate any natural falling bubbles! :)