Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5938

Python - Flip Referenced Curve?

$
0
0

Hello,

I have a python script I am working on that checks the orientation of a curve and flips it either clockwise or counterclockwise depending on a boolean value.

Everything is working except I can’t get the actual curves themselves flipped.

I realized the .reverse() method actually returns True or False if a curve was flipped but how do I actually flip the curve itself?

I found this topic but I am specifically trying to flip referenced curves in GH that may or may not have GUIDs from the Rhino model.

Do I flip the domain based on the true/false value?

I feel like I’m overlooking a really obvious fact. Thanks for the help!

Graph Space:

Code:

def orient_curves_consistently(C, B):
    Fc = []
    O = []
    F = []

    if C is not None:
        for curve in C:
            orientation = str(curve.ClosedCurveOrientation())
            O.append(orientation)

            #If B is True Flip All Curves CounterClockwise
            if B: 
                if orientation == "Clockwise":
                    reversed_curve = curve.Reverse()
                    Fc.append(reversed_curve)
                    F.append(True)  # Curve was flipped
                else:
                    Fc.append(curve)
                    F.append(False)  # Curve was not flipped
            else:
                if orientation == "CounterClockwise":
                    reversed_curve = curve.Reverse()
                    Fc.append(reversed_curve)
                    F.append(True)  # Curve was flipped
                else:
                    Fc.append(curve)
                    F.append(False)  # Curve was not flipped

    return Fc, O, F

if __name__ == "__main__":
    Fc, O, F = orient_curves_consistently(C, B)

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 5938

Trending Articles