logo

BUNDLING_SOLO

"""
Script written by Luis Quinones
www.luisquinonesdesign.com
www.computationalmatter.com
Script version Monday, 21 March 2011 20:18:46
"""
"""each grip point checks its position on the mesh
find the corresponding color value that is closest to it
that color value 0-1 determines the multiplier for the threshold"""

import rhinoscriptsyntax as rs
from System.Drawing import Color

def Main():
    strLayer = rs.AddLayer("ptStore", Color.White)
    crvArr = rs.GetObjects("Crvs",filter = 4)
    gens = rs.GetInteger("Generations",4)
    threshold = rs.GetReal("AttractionThreshold",80)
    for i in range(gens):  
        for j in range(len(crvArr)):           
            rs.EnableObjectGrips(crvArr[j],enable = True)
            gripCount = rs.ObjectGripCount(crvArr[j])           
            for k in range(gripCount-1):                
                gripPos = rs.ObjectGripLocation(crvArr[j],k)          
                count = 0
                for m in range(len(crvArr)):                 
                    crvParam = rs.CurveClosestPoint(crvArr[m],gripPos)
                    crvPt = rs.EvaluateCurve(crvArr[m],crvParam)
                    dist = rs.Distance(crvPt,gripPos)                                    
                    #print newThreshold
                    if dist < threshold and j != m :                       
                        if count == 0:                            
                            closestDist = dist
                            closestVec = rs.VectorCreate(crvPt,gripPos)                          
                            count += 1
                        else:                            
                            if dist < closestDist:                             
                                closestDist = dist
                                closestVec = rs.VectorCreate(crvPt,gripPos)
                                #closestVec = rs.VectorScale(closestVec,threshMult)                          
                                count += 1
                if count == 0:
                    closestVec = 0,0,0
                newPos = rs.VectorAdd(gripPos,closestVec)
                rs.ObjectGripLocation(crvArr[j],k,newPos)             
            rs.EnableObjectGrips(crvArr[j],False)
Main()
Update
  • Share