New site

Monday, August 18, 2008

Scripted Creature




Lately i have beeen working back with RhinoScript and as a prctice excercise i wanted to create a script wich helped me to create a generative sculpture like object.The result of playing around with this idea is this scripted creature. For the creation of this figure i developed a script wich works in a simple way , the user needs to input a set of points , the the script will elaborate a net work beetween those points withe a distance conditional then script will ask the user to select the created lines he wants to use for the creation of the structure , then script will complete the task making a lofted surface.





Here is the script perhaps it can be usfel to perform other tasks if you find one please let me know.

Option Explicit
'Script written by Rodrigo Medina Garcia
'Script copyrighted by designplaygrounds.blogspot.com
'Script version miércoles, 23 de julio de 2008 15:49:30

Call Main()
Sub Main()
Dim arrpts,strcrv,strcrv2,crvdomain,evapoints
Dim i,u,k,j
arrpts=rhino.GetPointCoordinates("select points for structure creation")
If isNull (arrpts) Then Exit Sub
For i = 0 To uBound(arrpts)
For u =0 To UBound(arrpts)
If Rhino.distance(arrpts(i),arrpts(u)) <80 Then Call lines(arrpts,i,u,strcrv)


Next
Call rhino.addsphere(arrpts(i),1)
Next

strcrv2=rhino.GetObjects("select the created line structures",4)

For k =0 To ubound (strcrv2)


crvdomain=rhino.CurveDomain(strcrv2(k))

For j= crvdomain(0)To crvdomain(1) Step crvdomain(1)/4
evapoints=rhino.EvaluateCurve(strcrv2(k),j)
arrpts=Rhino.AddPoint(evapoints)
If j = crvdomain(1)/2 Then
Call circles1(strcrv2,k,j)
ElseIf j <> crvdomain(1)/2 Then
Call circles2(strcrv2,k,j)
End If


Next
Call rhino.Command("_selnone _selclosedcrv -_loft _enter _enter _delete ")
Next


End Sub
Function lines(arrpts,i,u,strcrv)
strcrv=rhino.AddLine(arrpts(i),arrpts(u))
End Function
Function circles1(strcrv,k,j)
Dim frame,radi
frame=Rhino.curveperpframe(strcrv(k),j)
radi=2.5
Call rhino.AddCircle(frame,radi)

End Function
Function circles2(strcrv,k,j)
Dim frame,radi
frame=Rhino.curveperpframe(strcrv(k),j)
radi=1
Call rhino.AddCircle(frame,radi)

End Function

No comments:

Related Posts with Thumbnails