def pullBranch(self, stick):
     traits = stick.defineEnds()
     stick.end01 = rs.PullPoints(self.mesh, [traits[0]])[0]
     stick.end02 = rs.PullPoints(self.mesh, [traits[2]])[0]
     crvs = stick.draw()
     branch01 = rs.PullCurveToMesh(self.mesh, crvs[0])
     branch02 = rs.PullCurveToMesh(self.mesh, crvs[1])
     rs.DeleteObjects(crvs)
Exemplo n.º 2
0
def baseBranch(mesh,start,vec,ang,length,gen):
    end=rs.PointAdd(start,vec*length)
    end=rs.MeshClosestPoint(mesh,end)[0]
    branch1=rs.AddLine(start,end)
    projBranch1=rs.PullCurveToMesh(mesh,branch1)
    branches=[projBranch1]
    stored=branches
    newBranches=[]
    i=0
    count=0
    while i < gen:
        i=i+1
        for branch in branches:
            end=rs.CurveEndPoint(branch)
            param=rs.CurveClosestPoint(branch,end)
            vec=rs.CurveTangent(branch,param)
            vec=rs.VectorUnitize(vec)
            index=rs.MeshClosestPoint(mesh,end)[1]
            norm=rs.MeshFaceNormals(mesh)[index]
            vec=rs.VectorRotate(vec,ang,norm)
            start=rs.PointAdd(end,vec*length)
            start=rs.MeshClosestPoint(mesh,start)[0]
            newBranch=rs.AddLine(end,start)
            pulledBranch=rs.PullCurveToMesh(mesh,newBranch)
            rs.DeleteObject(newBranch)
            newBranches.append(pulledBranch)
            vec=rs.VectorRotate(vec,-2*ang,norm)
            start=rs.PointAdd(end,vec*length)
            start=rs.MeshClosestPoint(mesh,start)[0]
            newBranch=rs.AddLine(end,start)
            pulledBranch=rs.PullCurveToMesh(mesh,newBranch)
            rs.DeleteObject(newBranch)
            if rs.Distance(start,rs.CurveEndPoint(pulledBranch))<length/2:
                newBranches.append(pulledBranch)
        branches=newBranches
        stored.extend(branches)
        newBranches=[]
        count=count+1
    #for i in range(len(stored)):
    #    squareSect(stored[i],1,1)
    print count
    return stored