# SetSize() helper

• THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 28/02/2011 at 15:39, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   12
Platform:   Windows  ;
Language(s) :     C++  ;

---------
Hey everyone..  I made this little helper function that might be useful to some people.  I use it to resize objects using real cm measurements.    Hope you find it helpful.  I know this can be done using Scaling functions but this function allows you to use real size measurements instead of scalars.  Basically it converts your real measurements into scalars which are then used to scale the object.  :)

So instead of having to know that you are scaling the original size by 2, you can change the size of a cube from 200 to 400 without having to use scalars.

``````
//This function is used to resize objects.

void SetSize(BaseObject *op, Vector size){

//Get the radius for the original size
//Divide the current size by the original size..
Vector scalar = Vector(size.x / orig.x, size.y / orig.y, size.z / orig.z);

//Declare the Matrix
Matrix m;

//Normalize the Matrix Vectors
Vector normV1 = m.v1;
normV1.Normalize();
Vector normV2 = m.v2;
normV2.Normalize();
Vector normV3 = m.v3;
normV3.Normalize();

//Scale the Matrix by the determined scalar
m.v1 = normV1 * scalar.x;
m.v2 = normV2 * scalar.y;
m.v3 = normV3 * scalar.z;

//Set the objects Matrix to the new Matrix.
op->SetMl(m);
}
``````

BaseObject *op
This is the object that you wish to resize.

Vector size
This is the vector that represents the size of the object.  For example.  If you wish to use a Vector description from the attributes manager you would do the following.

``````
BaseContainer *bc = op->GetDataInstance();
SetSize(op, bc->GetVector(MY_VECTOR));
``````

Hope this helps someone.  :)

~Shawn

• THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 01/03/2011 at 10:08, xxxxxxxx wrote:

LOL..  It's a little bit like having a SetRad() function.  ;)