 # Function to scale according to the area ratio in rhinoscriptsyntax

I want to scale surface based on the area ratio.
I expect following function.
`function(srf_id, area_ratio)`
If I specify area_ratio = 0.5, returned geometry by this function have the half of the area compared to original one.

If you want to scale something you not only need a scale factor, you also need an origin point. The rhinoscriptsyntax method is rs.ScaleObject() - single guid, or rs.ScaleObjects() - guid list. the arguments are essentially the same. All the rhinoscriptsyntax methods can be found here, or if you are in the editor, F1 will call the help.

–Mitch

I think these functions can scale the length. But what I want to find is the function which can scale the object based on the area. Say, if I want to scale down the object 1m2 to 0.5m2, the function gonna be something like below.
ScaleArea(object_id,origin,scale_area)

Do you have any idea whether I can find these function or create?

To get the length scale factor, you need the square root of the desired area scale factor:

``````import rhinoscriptsyntax as rs
from math import sqrt

origin=rs.coerce3dpoint([0,0,0])
scale=0.5
obj=rs.GetObject("Select object to scale")
a0=rs.SurfaceArea(obj)
sf=sqrt(scale)
sobj=rs.ScaleObject(obj,origin,[sf,sf,sf],True)
a1=rs.SurfaceArea(sobj)
print "Orig. area: {}, New area: {} Area ratio: {}".format(a0,a1,a1/a0)
``````

–Mitch

1 Like