Attracted Flows
This is a rhinoscript where you can set various points where vectors flow out from according to a certain velocity. As these vectors travel, the flows are attracted to the various attractor points in different weights three dimensionally. It simulates a close logic to the emitted particles being attracted to newton forces in Maya.
—-
Option Explicit
‘Script written by Howard Jiho Kim / crtl-i.com
Call Main()
Sub Main()
Dim startPt, velocity
velocity = Array(10,0,0)
startPt = Rhino.GetObjects(“Select Start Points”,1)
‘Attractors / Distances
Dim no_attr, attr, attrStr, i
no_attr = Rhino.GetInteger(“How many attractors?”)
ReDim attr(no_attr-1), attrStr(no_attr-1)
For i=0 To no_attr-1
attr(i) = Rhino.GetObject(“Select Attractor ” & (i+1),1)
attrStr(i) = Rhino.GetReal(“Enter Strength for Attractor ” & (i+1))
Next
For i=0 To Ubound(startPt)
Flow velocity, startPt(i), no_attr, attr, attrStr, 35
Next
End Sub
Function Flow(velocity, startPt, no_attr, attr, attrStr, gens)
Dim vec1, vec0
vec1 = Rhino.VectorCreate(velocity, Array(0,0,0))
vec0 = Rhino.VectorCreate(Rhino.PointCoordinates(startPt), Array(0,0,0))
Dim totalDistance, distance, i
ReDim distance(no_attr-1)
Dim vec, finalVec, vec4, tagStop
tagStop = 0
ReDim vec(no_attr-1)
Dim newPt, newLine, endPt2
totalDistance=0
If gens>0 Then
For i=0 To no_attr-1
distance(i) = Rhino.Distance(Rhino.PointCoordinates(startPt), Rhino.PointCoordinates(attr(i)))
totalDistance = totalDistance + distance(i)
Rhino.Print distance(i)
Rhino.Print totalDistance
If distance(i) < 1 Then
gens = -1
End If
Next
‘Vectors
vec4 = vec1
For i=0 To no_attr-1
vec(i) = Rhino.VectorCreate(Rhino.PointCoordinates(attr(i)), Rhino.PointCoordinates(startPt))
vec(i) = Rhino.VectorUnitize(vec(i))
vec(i) = Rhino.VectorScale(vec(i), (attrStr(i)/distance(i))^2)
vec4 = Rhino.VectorAdd(vec4, vec(i))
Next
finalVec = Rhino.VectorUnitize(vec4)
finalVec = Rhino.VectorScale(finalVec, 1)
If tagStop = 0 Then
newPt = Rhino.AddPoint(finalVec)
newLine = Rhino.AddLine(Array(0,0,0), finalVec)
endPt2 = Rhino.MoveObject(newPt, vec0)
newLine = Rhino.MoveObject(newLine, vec0)
End If
Flow velocity, endPt2, no_attr, attr, attrStr, gens-1
End If
End Function




Attracted flows rhinoscript | Rhino Tuts Says: 27.07.09 at 5:00 am
[...] post can be found here. Filed under : Files and [...]
metasword Says: 31.07.09 at 7:21 am
I am using Rhino V4 SR5 and it gives an error.
crtl-i Says: 31.07.09 at 7:41 am
metasword.
i’m using SR5 as well. could you be more specific about the error?
perhaps try downloading the script from this page: http://crtl-i.com/blog/scripts/
metasword Says: 03.08.09 at 11:32 am
Sorry for the delay. Thanks for the link. It works fine now.