Hi all, Is there a command or script in grasshopper that move multiple objects away or closer to a set point? Basically a Space Expansion/Contraction command. I found a Rhino Script online that works pretty well, but requires distance inputs for every axis. I’d love to be able to use a slider to control the amount of expansion or contraction. The rhino script is attached.
There’s not a single component, but you can set up lines for each object to move along. For example you could use the boundingbox centre (always works) or the volume centroid (only works for closed volumes).
The little bit of vector algebra in the ‘Scaled Motion’ group makes it so that a slider value of 0.0 means the shapes are all exactly at the origin point, a slider value of 1.0 puts them where they started out, and any number bigger than that puts them further away.
If you want the motion to be constant for all shapes instead of based on their initial distance from the origin, then you must add a Unit Vector component just before the Multiply component. In that case the slider will encode actual distances rather than multiples of the initial distance.
Here’s a solution in Grasshopper2 using fields. I create a vector field which points away from the origin point with a constant strength (i.e. no falloff function). Then each shape is dragged along by the field.
Lot fewer components, but it only moves shapes away or towards the origin point by a fixed distance. You can’t make them all collapse onto the origin at the same time.
There are other ways besides Volume ‘C’ to get a single point for each geometry. If they are curves, you could use MidPt, for example. If open breps, you could use the average of all vertices from DeBrep, like this: