Grasshopper

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!

Views: 543

Replies to This Discussion

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.

yes,you r right!Djordje,thankyou

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);

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service