algorithmic modeling for Rhino
Hi all,
I need to unify the directions of a set of curves for a python code.
In order to achieve this in grasshopper, I was usually taking one item from the curves list and using it as a guide curve for the 'Flip Curve' component.
Now I'm trying to do this in python, but it doesn't seem to work properly, sometimes flipping curves that were already in the same direction with the first curve.
This is the code I tried:
import rhinoscriptsyntax as rs
def matchCrv(crv2,crv1):
flip = False
if rs.CurveDirectionsMatch(crv2, crv1):
print 'match'
else:
x = rs.ReverseCurve(crv2)
flip = True
print x
return flipF = []
for i in C:
tmpflip = matchCrv(i,C[0])
F.append(tmpflip)
and these are the logs from the 'Flip Curve' and from the code:
*all the curves are closed planar polylines
Only curve #5 had different direction from other curves, but in python curve #3 was flipped too.
Is there anything I'm missing here?
Thanks,
Michael
Tags:
Obviously, it does work if I call 'Flip Curve' component inside python, but I was hoping to avoid importing ghpythonlib:
from ghpythonlib import components as ghcomp
F = ghcomp.FlipCurve(C,C[0])[1]print F
----------------------------------
[False, False, False, False, False, True]
Works like magic
Thanks a lot Marcus!
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by