Esempio n. 1
0
import ghpythonlib.components as ghc
import ghpythonlib.parallel as ghp

#divide circle curves into pnts
indivpoints = {}
for circle in circles:
    points = ghc.DivideCurve(circle, splits, False)[0]
    for num in range(0, splits):
        indivpoints.update({num:[points[num]]}) if num not in indivpoints.keys() else indivpoints[num].append(points[num])

#create polylines from points at index between circles
polylines = [ghc.PolyLine(indivpoints[key], False) for key in indivpoints.keys()] 
polylines.append(polylines[0])#to allow a full loop

#create ruled surfaces between polylines
loftsdata = [[polylines[loft],polylines[loft+1]] for loft in range(0, splits)]

#running ruled surfaces in parallel compute
lofts = ghc.CapHoles(ghc.BrepJoin(ghp.run(lambda x: ghc.RuledSurface(x[0], x[1]), loftsdata, True))[0])
Esempio n. 2
0
import ghpythonlib.components as ghComp
import ghpythonlib.parallel as par
import rhinoscriptsyntax as rs

# DelaunayMesh and get vertices and faces
mesh = ghComp.DelaunayMesh(points, rs.WorldXYPlane())
vertices, faces, _, _ = ghComp.DeconstructMesh(mesh)

# uses faces if max distance of edges are shorter than or equal to the given threshold(cell size ^2 + 2*cell size^2)
newMesh = []


def face_distance(face):
    dist1 = rs.Distance(points[face.A], points[face.B])
    dist2 = rs.Distance(points[face.B], points[face.C])
    dist3 = rs.Distance(points[face.C], points[face.A])
    maxDist = max(dist1, dist2, dist3)
    if (maxDist <= threshold):
        newMesh.append(face)


par.run(face_distance, faces)

# create final meshes and use naked edges for boundary
finalMesh = ghComp.ConstructMesh(vertices, newMesh)
nakedEdges = finalMesh.GetNakedEdges()
Esempio n. 3
0
    if kk == depth and splits == 3:
        geo = ghc.ExtrudePoint(pgn,
                               endpnt)  #if last branch than make a pyramid
    else:
        geostraight = ghc.Extrude(pgn, nn)  #extrudes the polygon along vector
        geo = ghc.Taper(
            geostraight, nn, radius, radiusend, False, False, False
        )  #inputs: geometry, axis, start radius, end radius, flat (False), infinite (False), rigid (False)

    return ghc.CapHoles(geo)  #caps ends on the extruded brep


#iterate over branches and run ngons func
def makegeo(treelinsorted):
    for kk in treelinsorted.keys():
        for nn in treelinsorted[kk]:
            args = [
                nn, length, lvariation, kk, radtolen, mngon, depth, radchng
            ]
            pgons.append(ngons(args))


ghp.run(makegeo, [treelinsorted], True)


def joiner(breps):
    return ghc.SolidUnion(breps)


#joined = joiner(pgons)
                        verticality, gchance, depthstart, radtolen, radchng,
                        mngon, polygon, branch_cluster)


#first recursive function call
fractal(depth, x1, y1, z1, x2, y2, z2, length, anglerec, angle, lvariation,
        aran, lran, anglerech, angleh, branches, verticality, gchance,
        depthstart, radtolen, radchng, mngon, polygonbase, branch_cluster)

data_for_parallel = []
data_single = []
for key in pgons.keys():
    if len(pgons[key]) < 2:
        data_single.append(pgons[key][0])
    else:
        branch_geo = []
        for nn in pgons[key]:
            branch_geo.append(nn)
        data_for_parallel.append(branch_geo)


def joiner(breps):
    return ghc.SolidUnion(breps)


joined = ghp.run(joiner, data_for_parallel, True)
treeoutput = [joined, data_single]

#print(cluster)
#print(pgons)
#print(data_for_parallel)