 How to scale 3d model to target volume, while maintaining same height

Hello,

I’m new to grasshopper and would appreciate your help. I’m trying to scale a geometry to a target volume, while maintaining the same height. It should scale equally in the x and y dimensions, while maintaining same z dimension. The idea is to make it work for different shapes that are not defined by a single volume equation (like a box where volume is length x width x height).

I know the geometry can be scaled uniformly like this:

But my attempts at non-uniform scaling have not been successful, and I am only guessing the scaling factors at this point. How can the scaling factors be determined for x and y so that z=1 and the target volume is reached?

Please see attached .gh file, it looks like this:

on the right(scale in xyz), the geometry is scaled in all directions as in the picture above.
On the bottom (scale non-uniform), I tried using non-uniform scaling components from pufferfish and grasshopper. I’m stuck here and I’m not sure how to proceed. Any help is appreciated.
Here is the bottom part of the script up close:

Scaling_to_volume.gh (34.4 KB)

There are an infinite number of solutions, if I understand you correctly. The original volume is 13439 and the target is 10000, so you first of all want it reduced by that ratio, = .744. Since z stays the same (=1) the factors for x and are such that x*y = .744. So choose an x and then y=x/.744
If you want x=y, then do as @davidcockey says and x^2=.744, so x =sqrt(.744) = .863

Scaling_to_volume-b.gh (34.5 KB)

For equal scaling in x and y with z not scaled use scale factor of:
square root of (target volume / original volume)

1 Like Trial and error the Galapagos way. For more precision, I increased the slider from 2 to 5 decimal points. It might be faster if the range of the slider was reduced?

Scaling_to_volume_2021Dec24a.gh (30.0 KB)

Years ago I wrote a general purpose “solver” using Anemone. Will try that next.

P.S. Doh! @davidcockey got it right. Three cheers for the thinking man!

Scaling_to_volume_2021Dec24b.gh (28.9 KB)

Thank you for your replies! You’ve helped a lot.