090918-Geometry Study 3

fluid

Considering the behavior of my substance. It transform from between liquid and solid.  I made the geometry after squeeze and flow out. Each sphere-like space is where maching(mode) takes effect. The spay part is where the substance flow down. Though it looks unsuccessful. 😦

Option Explicit
‘Script written by Shuang Xu
‘Script copyrighted by <insert company name>
‘Script version 2009年9月15日 4:51:33

Call Main()
Sub Main()
 Dim strcurve,number,i,arrdivpt,radius1,radius2
 strcurve=rhino.getobject(“curve”)
 number=rhino.getinteger(“number of division”,8)
 radius1=rhino.GetReal(“radius1”,0.3)
 radius2=rhino.GetReal(“radius2”,0.8)
 arrdivpt=rhino.DivideCurve(strcurve,number)
 
 Dim arrparam(),arrnormal(),arrplane()
 For i=0 To number
  ReDim Preserve arrparam(number)
  ReDim Preserve arrnormal(number)
  ReDim Preserve arrplane(number)
  ReDim Preserve arrcircle(number)
 
  arrparam(i)=rhino.CurveClosestPoint(strcurve,arrdivpt(i))
  arrnormal(i)=rhino.CurveCurvature(strcurve,arrparam(i))(1)
  arrplane(i)=rhino.PlaneFromNormal(arrdivpt(i),arrnormal(i))
 Next
 
 Dim j, arrcircle1(),arrcircle2(), arrcircle3(),arrcircle4(),arrcircle5(),arrcircle6()
 For j=0 To number-4 Step 4
  ReDim Preserve arrcircle1(number)
  ReDim Preserve arrcircle2(number)
  ReDim Preserve arrcircle3(number)
  ReDim Preserve arrcircle4(number)
  ReDim Preserve arrcircle5(number)
  ReDim Preserve arrcircle6(number)
  
  arrcircle1(j)=rhino.AddCircle(arrplane(j),radius1)
  arrcircle2(j)=rhino.AddCircle(arrplane(j+1),radius2)
  arrcircle3(j)=rhino.AddCircle(arrplane(j+2),radius1)
  arrcircle4(j)=rhino.AddCircle(arrplane(j+3),radius1)
  arrcircle4(j)=lianxian(arrcircle4(j),18)
  arrcircle5(j)=lianxian(rhino.AddCircle(arrplane(j+2),radius2),18)
  arrcircle6(j)=rhino.AddCircle(arrplane(j+4),radius1)
  
 Next
 
 
 Dim k
 For k=0 To ubound(arrcircle6)
  Call rhino.addloftsrf(array(arrcircle1(k),arrcircle2(k),arrcircle3(k)),arrcircle4(k),arrcircle5(k),arrcircle6(k))
 Next
End Sub

Function lianxian(object,number)
 Dim arrpts, center,arrlines(),m,arrscalelines(),scale
 arrpts=rhino.DivideCurve(object,number)
 center=rhino.CircleCenterPoint(object)
 For m=0 To number-1
  ReDim Preserve arrlines(number-1)
  ReDim Preserve arrscalelines(number-1)
  
  arrlines(m)=rhino.addline(center,arrpts(m))
  scale=rnd*1.3+1
  arrlines(m)=rhino.ScaleObject(arrlines(m),center,array(scale,scale,scale))
 Next
 
 Dim n,arrendpt()
 For n=0 To ubound(arrlines)
  ReDim Preserve arrendpt(ubound(arrlines))
  arrendpt(n)=rhino.CurveEndPoint(arrlines(n))
 Next
 lianxian=rhino.AddCurve(array(arrendpt(0),arrendpt(1),arrendpt(2),arrendpt(3),arrendpt(4),arrendpt(5),arrendpt(6),arrendpt(7),arrendpt(8),arrendpt(9),arrendpt(10),arrendpt(11),arrendpt(12),arrendpt(13),arrendpt(14),arrendpt(15),arrendpt(16),arrendpt(17),arrendpt(0)))
 Call rhino.deleteobjects(arrlines)
 Call rhino.DeleteObject(object)

End Function

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s