Grasshopper

algorithmic modeling for Rhino

Would anyone know if there is a Python function for reparameterizing a curve (setting its domain to (0,1))? I have looked in both the RhinoScript and RhinoCommon documentation with no luck. I'm still rather new to Python so I may have missed something.

Thanks,

/Anders

Views: 3761

Replies to This Discussion

in c# it would be: curve.Domain = new Interval(0,1);

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Thanks, David. From your pointer I did this:

c = rs.coercecurve(c)
i = rc.Geometry.Interval(0,1)
rc.Geometry.Curve.Domain.SetValue(c,i)

Seems to work.

Hi Anders

c_ref = rs.coercecurve(c)
c_ref.Domain = rc.Geometry.Interval(0,1)

should do, too.

Usually users of the RhinoScript library use rs.CurveParameter(), that transforms a 0-1 parameter to a curve parameter. But assigning a new interval might be a good way in some cases, too.

Thanks,

- Giulio
_______________
giulio@mcneel.com

Thanks Giulio, that makes it much clearer. I did fiddle a bit with the rs.CurveParameter() function as well. But, as you said, sometimes assigning a new interval is the way to go. Basically I was feeding a list of curves from a geometry pipeline component through a reparameterized curve parameter into the python component. Just wanted to get rid of that curve parameter in order to keep it a bit more "clean". So I think that this could be considered one of those cases you speak of :)

Thanks again,

Anders

Hi again,
There seems to be an issue with setting the domain on PolyCurves (which I got from splitting a list of PolyLines). In the attached file the PolyCurves appear to have been reparameterized (if one prints their domain it is correctly shown to be 0,1). However if one plots a point at 0,5 and compares this with Grasshoppers own CurvePoint it is clear that there is something funky going on. Any ideas?
Best,
Anders

(This is running GH 0.80066 with Rhino Version 5.0  (5.1.20918.2135, 09/18/2012) by the way.)

Attachments:

Solved it. I had to use the PointAtNormalizedLength function instead of just PointAt. Dooh!

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

© 2020   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service