Grasshopper

algorithmic modeling for Rhino

Hello,

I try to script in ghPython the GH Component "Length Parameter (LenP)".
In GH, after giving a curve and a point on this curve, you receive as a output the length of the curve before and after this point (L- and L+).
Is there a way to get the same values by scripting with python, using rhinoscriptsynthax or Rhino.Geometry ?
I can't find it.
If not, can you give me some hint to script it using an other method?


Thanks a lot.

Best, 

Roger

Views: 945

Replies to This Discussion

Hi Roger

this is the evaluation of the arclength of the curve from [the start of the domain, to t] and from [t, to the end of the domain].

with RhinoScriptSyntax,

domain = rs.CurveDomain(id)
rs.CurveLength(id, sub_domain=[domain[0],t])


with RhinoCommon,

Curve.GetLength(Interval) 

does this.

Does it help, or do you need a full sample?

Thanks,

Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

Hi Roger,

Curve.GetLength method has an optional parameter "subdomain". You can use the "p" curve parameter as a boundary value for your subdomain (starting or ending value):

import Rhino

interL1 = Rhino.Geometry.Interval(crv.Domain[0],p)
interL2 = Rhino.Geometry.Interval(p, crv.Domain[1])
l1 = crv.GetLength(interL1)
l2 = crv.GetLength(interL2)

ghpythonlib.components function should work too:

import ghpythonlib.components as gh

l1, l2 = gh.LengthParameter(crv,p)

EDIT: Haven't refreshed the page, before replying. My apology Giulio.

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