Is there Space Expansion/Contraction command in grasshopper?

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.

CompressExpandSpace.rvb (2.3 KB)

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).

Here’s a file:
expand.gh (11.9 KB)

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.

expand g2.ghz (6.3 KB)

Actually I think that’s not true. You can make that happen if the falloff is a linear function which intersects (0,0)

testing

yeah, it works:

Difference is that now -1.0 means collapse all the way to the origin point and 0.0 means keep in original place.

Also if instead of a Point Field you create a Distance Field, you can use any shape as the collapse locus. Lines, circles, surfaces, …

Wow! Thank you David! I feel like it is going to be years before I understand all of the components in GH. I am enjoying learning it though.

I truly appreciate the help.

Honeycam 2024-02-16 09-13-35
Nautilus

3 Likes

Thank you! can you show the grasshopper algorithm?

What is a ‘.rvb’ file?

This uses MoveAway. Volume is orange because these are not closed breps, but it works.


MoveAway_2024Feb20a.gh (14.1 KB)

Or:


MoveAway_2024Feb20b.gh (13.0 KB)

1 Like

Rhino Visual Basic, or RhinoScript.

Thank you!

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:


MoveAway_2024Feb21a.gh (14.2 KB)