Grasshopper

algorithmic modeling for Rhino

Since starting to type out this question, I managed to get it working but since it took me longer than I would like to admit, I decided to still post it for future reference and ask a different question relating to SDK (excuse the naivete). 

I was trying to orient (change basis) a curve to a list of planes however, the changeBasis method was cumulatively moving my curve to a place where I didn't want it. Now this works fine for points because I can instantiate them on each iteration but curves can't be instantiated like that. So what's special about curves? Breps, Vectors, points etc. can be instantiated but why not Curves?

private void RunScript(Curve crv, Point3d pt, List<Plane> pl, ref object A, ref object B)
{
List<Curve> crvLst = new List<Curve>();
List <Point3d> ptLst = new List<Point3d>();

for (int i = 0; i < pl.Count(); i++)
{
Point3d point = new Point3d(); //new point- things are good
Curve curve;

point = pt;
//curve = crv; //this was the problem

curve = crv.DuplicateCurve(); //fix
Transform xform = Transform.ChangeBasis(pl[i], Plane.WorldXY);

point.Transform(xform);
curve.Transform(xform);

crvLst.Add(curve);
ptLst.Add(point);
}

A = crvLst;  //was causing problems
B = ptLst;   //all good
}

Views: 434

Replies to This Discussion

Hi Tom,

Thanks for the explanation!

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