## Wednesday, October 15, 2014

### vector surface attractor | rhinoscript python

In this tutorial I utilize a surface domain script, vectors, and an attractor point to manipulate the directionality of simple geometry. Code available here. Total Length: 14.30

Unknown said...

Hurrah, that's what I was searching for, what a information! existing here at this weblog, thanks admin of this website. gmail email login

Unknown said...

Very helpful, but how do you get objects to start responding to the attractor point? for example, I am trying to get surfaces in my script to start turning/responding to the sun (the attractor point). Below is my current script. I want to get the triangle aggregation to start responding to sun conditions, but I'm not sure how to go about it.

import scriptcontext
import rhinoscriptsyntax as rs
import random as rd
from math import atan2, degrees

SrfList = []

#define the function

def DivideTriangleSrf(srf,delete,scaleFactor):

#duplicate the border and return a list

surfaceBorderlist = rs.DuplicateSurfaceBorder(srf, 1)
if len(surfaceBorderlist)>0:
Border = (surfaceBorderlist)

#get line segments from the border as individual curves

linesegments = rs.ExplodeCurves(Border)

linesegment1 = linesegments

linesegment2 = linesegments

linesegment3 = linesegments

curvelenght = (rs.CurveLength(linesegment1))

#calculate the middle points

midPoint1 = rs.CurveMidPoint(linesegment1)

midPoint2 = rs.CurveMidPoint(linesegment2)

midPoint3 = rs.CurveMidPoint(linesegment3)

#calculate the vertex

vertexPoints = rs.CurvePoints(Border)

point1 = vertexPoints

point2 = vertexPoints

point3 = vertexPoints

#calculate the vectors

normalVectors = rs.SurfaceNormal(srf,(0,0))

normalVectors = rs.VectorScale(normalVectors,curvelenght*scaleFactor)

#since normal vector is by default 0-based, I add it to the midPoints

#For further subdivision

if(curvelenght>4):

DivideTriangleSrf(baseSrf,delete,scaleFactor)

DivideTriangleSrf(triangleSrf1,delete,scaleFactor)

DivideTriangleSrf(triangleSrf2,delete,scaleFactor)

DivideTriangleSrf(triangleSrf3,delete,scaleFactor)

SrfList.append(baseSrf)

SrfList.append(triangleSrf1)

SrfList.append(triangleSrf2)

SrfList.append(triangleSrf3)

if(delete):

rs.DeleteObjects((baseSrf,triangleSrf1,triangleSrf2,triangleSrf3))

rs.DeleteObject(Border)

#define variables

theSurface = rs.GetObjects("selectsurface that is defined by at least 3 points",8)

chooseDelete = rs.GetString("Do you want to delete the surfaces?",None)

scaleFactor = rs.GetReal("Enter scale factor",0.25,0.1,4)

#Call the function
for i in theSurface:
DivideTriangleSrf(i,chooseDelete,scaleFactor)

rs.DeleteObjects(theSurface)

#def FacetheSun():