<commit_before>#Python Workshop Lesson:24
#http://designalyze.com/int2pythonscripting24_MoreRecursionPt2
#cracking algorithm
import rhinoscriptsyntax as rs
import Rhino
import scriptcontext



def crackpolygon(pls, count):
    temppls = pls
    pls = []
    if count == 0:
        return 1
    else:
        for pl in temppls:
            if rs.CloseCurve(pl) == False:
                print "Not a closed curve"
            else:
                #print "Cool"
                centroid = rs.CurveAreaCentroid(pl)
                centpt = rs.AddPoint(centroid[0])
                curves = rs.ExplodeCurves(pl)
                for crv in curves:
                    #print crv
                    pt1 = rs.CurveStartPoint(crv)
                    pt2 = rs.CurveEndPoint(crv)
                    pts = []
                    pts.append(pt1)
                    pts.append(pt2)
                    pts.append(centpt)
                    pts.append(pt1)
                    newpl = rs.AddPolyline(pts)
                    pls.append(newpl)
                    rs.DeleteObject(crv)
                cleanup = []
                cleanup.append(centpt)
                #cleanup.append(curves)
                rs.DeleteObjects(cleanup)
        count = count - 1
        return crackpolygon(pls, count)

count = rs.GetInteger("How many iterations would you like to do?", 3)
pl = rs.GetCurveObject("pick a closed curve to crack")
plguid = pl[0]
polygons = []
polygons.append(plguid)
crackpolygon(polygons, count)<commit_msg>removed some comments<commit_after>#Python Workshop Lesson:24
#http://designalyze.com/int2pythonscripting24_MoreRecursionPt2
#cracking algorithm
import rhinoscriptsyntax as rs
import Rhino
import scriptcontext



def crackpolygon(pls, count):
    temppls = pls
    pls = []
    if count == 0:
        return 1
    else:
        for pl in temppls:
            if rs.CloseCurve(pl) == False:
                print "Not a closed curve"
            else:
                centroid = rs.CurveAreaCentroid(pl)
                centpt = rs.AddPoint(centroid[0])
                curves = rs.ExplodeCurves(pl)
                for crv in curves:
                    pt1 = rs.CurveStartPoint(crv)
                    pt2 = rs.CurveEndPoint(crv)
                    pts = []
                    pts.append(pt1)
                    pts.append(pt2)
                    pts.append(centpt)
                    pts.append(pt1)
                    newpl = rs.AddPolyline(pts)
                    pls.append(newpl)
                    rs.DeleteObject(crv)
                cleanup = []
                cleanup.append(centpt)
                rs.DeleteObjects(cleanup)
        count = count - 1
        return crackpolygon(pls, count)

count = rs.GetInteger("How many iterations would you like to do?", 3)
pl = rs.GetCurveObject("pick a closed curve to crack")
plguid = pl[0]
polygons = []
polygons.append(plguid)
crackpolygon(polygons, count)
{'fraction_non_alphanumeric': 0.08597748208802457, 'fraction_numerical': 0.01160013647219379, 'mean_word_length': 1.560698689956332, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1733329', 'n_tokens_mistral': 906, 'n_tokens_neox': 843, 'n_words': 194}