Goodevening to everyone,
i am going to ask you all a very basic question but i am starting to code with python these days.
i should need to scale an object (uniform scale) till it reach a set volume value to stop, reading wich scaling factor has been used.
following what i've done so far:
mesh = x
center = rs.MeshVolumeCentroid(x)
scaling_factor = 0
target_volume = 400
while scaling_factor < 10000:
LOOP = rs.scaleObject(x,center,scaling_factor)
if rs.MeshVolume(LOOP) == target_volume:
break
a = LOOP
Hope you can help me. I am trying to translate a grasshopper definition made with ANEMONE into python.
Thank you very much in advance
Nick
Tom Svilans
The volume will never (or extremely rarely) be exactly 400, so you have to check when it goes over (>= instead of ==). Then just output the scaling_factor and the temp object as well if you wish.
You also have to choose how your scaling factor will grow... Will it grow linearly? Or exponentially?
Oct 24, 2017