Hi all,
I tried to to use GetNextDiscontinuity in Rhino Common to get the same result like the curve " Discontinuity " in grasshopper.
But i have no idea how to use it.
A small example would be great.
Thanks in advanced
Hi all,
I tried to to use GetNextDiscontinuity in Rhino Common to get the same result like the curve " Discontinuity " in grasshopper.
But i have no idea how to use it.
A small example would be great.
Thanks in advanced
I recently implemented it in GHPython like so, might help:
import Rhino as rc
def discontinuity(crv):
""" Find G1_continuous discontinuities on a curve """
# Get curve domain min/max
tMin = crv.Domain.Min
tMax = crv.Domain.Max
# Perform search
dctParams = []
dctPoints = []
getNext = True
while getNext:
getNext,t = crv.GetNextDiscontinuity(rc.Geometry.Continuity.G1_continuous,tMin,tMax)
if not rc.RhinoMath.IsValidDouble(t):
t = 0.00
dctParams.append(t)
dctPoints.append(crv.PointAt(t))
if getNext:
tMin = t
return dctParams,dctPoints
Does admittedly seem a bit convoluted/complex having to implement a while loop, I might be missing a simpler approach here.
Thanks for your example
I am getting some unexpected errors when using the above with closed curves. It seems to be fixed with the below amendment.
def discontinuity(crv):
continuity = Rhino.Geometry.Continuity.G1_continuous
# Get curve domain min/max
tStart = crv.Domain.Min
tMin = tStart
tMax = crv.Domain.Max
# Perform search
dctParams = []
dctPoints = []
getNext = True
while getNext:
getNext, t = crv.GetNextDiscontinuity(continuity, tMin, tMax)
if not Rhino.RhinoMath.IsValidDouble(t):
t = tStart
dctParams.append(t)
dctPoints.append(crv.PointAt(t))
if getNext:
tMin = t
return dctParams,dctPoints