algorithmic modeling for Rhino
private void RunScript(Curve x, double y, ref object A)
{
AreaMassProperties.Compute(x).Centroid.X = 2;
AreaMassProperties.Compute(x).Centroid.Y = 4;
AreaMassProperties.Compute(x).Centroid.Z = 3;
}
but it doesnot work....the error is: centroid is a return value....
someknow how to set position?
yes ,of course i can use transform,but you need to calculate the vector which minus the origin position...it takes time and not efficient...i just need to set the final centroid position of curve...
Thank you!
Tags:
Hi Andrea,
Not all properties could be set. AreaMassProperties properties being one of those.
So, yes, you would have to do it by using Transform.
You're in luck, because transformations are easy and really fast!
Point3d currentCentroid = AreaMassProperties.Compute(x).Centroid;
Point3d targetCentroid = new Point3d(2,4,3);
// bit counter intuitive: subtracting two points
// gives a vector in the direction of to - from.
Vector3d transformVector = TargetCentroid - CurrentCentroid;
Transform translation = Transform.Translation(transformVector);
x.Transform(translation);
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by