logo

[F]antastic + Interactive

Gallery details

Self Organizing Curves + Point Attractors Influence – Grasshopper + Python Research V.1 [28.June.2011] – via GH_Python

“””Organizes the Curves by using a threshold value based on distances between each curve pt. A second set of Independent attractors in the form of points adds a new range of influence to the self organizing system .”””

GH_PYTHON
GH Python Code
Script written by Luis Quinones
Script copyrighted by [n]igma
www.luisquinonesdesign.com
www.cargocollective.com/studioboom
Script version Tuesday, 28 June 2011 20:18:46


import math
import rhinoscriptsyntax as rs
AttractorPtsList = []
for z in range(len(AttractorPts)):
    AttractorPtsList.append(AttractorPts[z])
for i in range(Gens):    
        for j in range(len(Curves)):         
            arrNewPos = []
            PointCount = rs.CurvePointCount(Curves[j])
            arrCrvDiv = rs.CurvePoints(Curves[j])            
            if arrCrvDiv:
                print "BOOM"
            else: 
                print "SHITBAG"             
            for k in range(PointCount):              
                arrCrvPts = []              
                if AttractorPtsList:                  
                    print AttractorPtsList                  
                indexClosestAtt = rs.PointArrayClosestPoint(AttractorPtsList,arrCrvDiv[k])
                print "Closest Index = ",indexClosestAtt
                attPt = AttractorPts[indexClosestAtt]
                print attPt
                dist2 = rs.Distance(attPt,arrCrvDiv[k])               
                if dist2 < attPtThresh :                  
                    NewPosition = attPt              
                else:                  
                    count = 0                  
                    for L in range(len(Curves)):                                             
                        if j != L :                                                        
                            arrCrvParam = rs.CurveClosestPoint(Curves[L],arrCrvDiv[k])                    
                            crvPt = rs.EvaluateCurve(Curves[L],arrCrvParam)                            
                            arrCrvPts.append(crvPt)                            
                    IndClosestCrv = rs.PointArrayClosestPoint(arrCrvPts,arrCrvDiv[k])
                    print "NextClosestIndex = ",IndClosestCrv
                    crvPt = arrCrvPts[IndClosestCrv]
                    print crvPt                  
                    dist = rs.Distance(arrCrvDiv[k],crvPt)                                   
                    if dist < Attract :                        
                        vector = rs.VectorCreate(crvPt,arrCrvDiv[k])
                        vector = rs.VectorScale(vector,dblRatio)
                        NewPosition = rs.VectorAdd(vector,arrCrvDiv[k])                        
                    else:                        
                        NewPosition = arrCrvDiv[k]                        
                arrNewPos.append(NewPosition)            
            newcurve = rs.AddCurve(arrNewPos,Rebuild)
            #newcurve = rs.AddPolyline(arrNewPos)
            rs.DeleteObject(Curves[j])
            #rs.ObjectColor(newcurve,[j,j,j])
            Curves[j] = newcurve        
if "ghdoc" in globals():
    a = ghdoc
Update
  • Share

Leave a reply

Your email address will not be published.