preferably with python
Hi @ivelin.peychev, below should do it, using RhinoScriptSyntax:
import rhinoscriptsyntax as rs def DoSomething(): # get the object (surface, polysurface or extrusion) obj_id = rs.GetObject("Brep to scale", 8+16+1073741824, True, False) if not obj_id: return # get area centroid and error bounds rc = rs.SurfaceAreaCentroid(obj_id) if not rc: return # the centroid and error bound centroid, error_bound = rc # scale 0.5 in xyz rs.ScaleObject(obj_id, centroid, [0.5, 0.5, 0.5], copy=False) DoSomething()
or should i show the RhinoCommon equivalent ?
Yes, I’m currently trying to use less rhinoscriptsyntax in order to learn RhinoCommon’s api better.
Also I think about 3d brep. But I got how to find the centroid in another thread.
I’ll try to do it myself. Thanks a lot.
On your brep, passing it:
This is what I did
transfIn = Rhino.Geometry.Transform.Scale(Rhino.Geometry.Plane(Rhino.Geometry.AreaMassProperties.Compute(B).Centroid,Rhino.Geometry.Vector3d.XAxis,Rhino.Geometry.Vector3d.YAxis),0.999,0.999,0.999) transfOut = Rhino.Geometry.Transform.Scale(Rhino.Geometry.Plane(Rhino.Geometry.AreaMassProperties.Compute(B).Centroid,Rhino.Geometry.Vector3d.XAxis,Rhino.Geometry.Vector3d.YAxis),1.001,1.001,1.001) BdupIn.Transform(transfIn) BdupOut.Transform(transfOut)
If you’re doing a uniform scaling, you don’t need the plane. Using the first overload above is simpler.
I wondered why I need a plane there