Transformation scale
-
Here is what i want to do:
Scale an object in ZSeems simple but the whole points-geometry-transformation thing is not always very clear to me
I know if i want to scale the first selected object 50% in z then this is the code:new_transformation=Geom;;Transformation.scaling thepoint,1,1,0.5 select[0].transformation=new_transformation
Now, thepoint, should be the base point of scaling (I think). Which should be the center point of the bottom face of the bounding box.
I found this script to determine the center point of the top face of the bounding box:bb = Geom;;BoundingBox.new bb.add(select[0].bounds) if select[0].respond_to?("bounds") xmin=bb.min.x;ymin=bb.min.y;xmax=bb.max.x ymax=bb.max.y;zmin=bb.min.z;zmax=bb.max.z apex=Geom.linear_combination(0.5,[xmin,ymin,zmax+2],0.5,[xmax,ymax,zmax+2])
Credits to who-ever wrote this!
When I use that I suspect the entity should be scaled 50% upwards (since i use the top center point) and that the entity stays on the same spot.
But somehow it moves to the origin. (with the 50% upwards scaling)
What don't I understand?
-
ok i've found it here: http://forums.sketchucation.com/viewtopic.php?f=180&t=24947&p=213942
use .transform! instead of .transformation
.transform adds the specified transformation to the already existing one
.transformation replaces the current transformation (like in: will put the object back to 0,0,0)
Advertisement