New site

Thursday, September 25, 2008

complex surface structures




Back into rhinoscipting here is a project i have developed for making a buildable structure from complex surface , the script takes an input surface and then it divides it in square sections, then it runs a macro wich makes an "x" form component in each squared sections. some improvements are posible you could add more pipe sections around each section, any way to understand it better here is the code feel free to use it and let me know any comments please.
Option Explicit
'Script written by Rodrigo Medina
'Script copyrighted by designplaygrounds
'Script version Tuesday, August 12, 2008 5:45:47 PM

Call Main()
Sub Main()
Const Objecttype=8

secu=15
secv=15

ReDim collec(secu,secv)
'inputs
Dim strsurface,Udomain,Vdomain,Uparam,Vparam,arrpoints,i,j,secu,secv
strsurface=rhino.GetObject("select surface",Objecttype)
If IsNull (strsurface) Then Exit Sub
'surface domains
Udomain=Rhino.SurfaceDomain(strsurface,0)
Vdomain=Rhino.SurfaceDomain(strsurface,1)
'looping
For i= 0 To secu
For j =0 To secv
Uparam=Udomain(0)+ i*((Udomain(1)-Udomain(0))/secu)
Vparam =Vdomain(0) + j*((Vdomain(1)-Vdomain(0))/secv)
arrpoints=rhino.evaluatesurface(strsurface,array(Uparam,Vparam))
'Rhino.AddPoint arrpoints
' function its only for making smooth unions between elements
'Call rhino.addsphere(arrpoints,1)
'charge the 2 diomension array with the size in i and j
collec(i,j)= arrpoints

Next

Next
'names for the points inside the array
Dim npoint1,npoint2,npoint3,npoint4
'position of the poinst inside of the array
For i= 0 To secu -1
For j= 0 To secv -1
npoint1=collec(i,j)
npoint2=collec(i+1,j+1)
npoint3=collec(i+1,j)
npoint4=collec(i,j+1)
Call pipe(npoint1,npoint2)
Call pipe(npoint3,npoint4)

Next
Next

End Sub

Function pipe(npoint1,npoint2)
Dim strline,strcmd,pipeRadius
strline= rhino.addline(npoint1,npoint2)
'radius of the pipe element
pipeRadius=1
strcmd ="! _Pipe _SelID " & strline & " " & pipeRadius & " _Enter _Enter"
Call rhino.command(strcmd)
End Function
Function pipe(npoint3,npoint4)
Dim strline2,strcmd,pipeRadius
strline2= rhino.addline(npoint3,npoint4)
pipeRadius=1
strcmd ="! _Pipe _SelID " & strline2 & " " & pipeRadius & " _Enter _Enter"
Call rhino.command(strcmd)
End Function

1 comment:

Yerko "Silver" Lucic said...

hola rodrigo, te he estado siguiendo aqui en tu blog...excelentes experimentos y trabajos..

estoy haciedo mi memoria en la universidad, y empezando con grasshopper, porque estoy viendo el tema de parametrizar componentes y fabricarlos digitalemte.....la cosa es que he estado haciendo varias cosas en GH, y ahora quiero hacer un "space frame" pero triangulado, como lo de este post.....me podrias dar alguna ayuda sobre que componentes se podrian usar??, he estado intentando con Shift, pero sin buenos resultados...

eso..hasta luego.

Related Posts with Thumbnails