rvb Surface Stair

rvb animation snippet example

Or how to dinamically create a nice design for a stair in no time. Just be careful with the inpput geometry and everything will be fine

Option Explicit

'Script written by Adolfo Nadal

'Script by archiologics · www.archiologics.com

 

Call Main()

Sub Main()

Dim strsur,arrstartpt,arrendpt,dblinterval

Dim disstep,dis,n

Dim arrcontour,arrcontour2

Dim arrbox

 

strsur=rhino.GetObject("Select a surface")

arrbox=rhino.BoundingBox(strsur)

arrstartpt=arrbox(2)

arrendpt=arrbox(6)

disstep=rhino.GetReal("type distance between 2 steps",0.15)

dis=rhino.Distance(arrstartpt,arrendpt)

n=int(dis/disstep)

dblinterval=dis/n

 

arrcontour=rhino.AddSrfContourCrvs(strsur,arrstartpt,arrendpt,dblinterval)

arrcontour2=rhino.CopyObjects(arrcontour,array(0,0,0),array(0,0,dblinterval*-1))

 

Dim Crvtop,CrvtopCopy,CrvEdge

Dim i

Dim arrMidPt()

Dim max

 

max=0

CrvEdge=rhino.DuplicateEdgeCurves(strsur)

For i=0 To ubound(CrvEdge)

ReDim Preserve arrMidPt(i)

arrMidPt(i)=rhino.CurveMidPoint(CrvEdge(i))

If arrMidpt(i)(2)>max Then

max=arrMidpt(i)(2)

crvtop=CrvEdge(i)

End If

Next

CrvtopCopy=rhino.CopyObjects(array(Crvtop),array(0,0,0),array(0,0,dblinterval*-1))

Dim t

Dim crv

Dim m:m=ubound(arrcontour)

For t=0 To m-1

crv=blendCrv(arrcontour(t),arrcontour2(t+1))

Call rhino.AddLoftSrf(array(crv,arrcontour(t+1)))

Call rhino.addloftsrf(array(crv,arrcontour(t)))

Next

Dim Crvlast

Dim blnCompare

Crvlast=blendCrv(arrcontour(m),Crvtopcopy(0))

blnCompare=rhino.CurveDirectionsMatch(Crvlast,Crvtop)

If   Not blnCompare=True Then

Call rhino.ReverseCurve(Crvtop)

End If

Call rhino.AddLoftSrf(array(Crvlast,Crvtop))

Call rhino.AddLoftSrf(array(Crvlast,arrcontour(m)))

Call rhino.HideObject(strsur)

End Sub

Function blendCrv(contourCrv,contourCrv2)

Dim k1,k2,k3,k4,k5,k6,k7,k8

k1=0.05

k2=0.1

k3=0.2

k4=0.4

k5=1-k4

k6=1-k3

k7=1-k2

k8=1-k1

 

Dim pt1,pt2,pt3,pt33,pt333,pt4,pt44,pt444,pt5,pt55,pt555,pt6,pt66,pt666,pt7,pt8

Dim startpt,endpt

startpt=rhino.CurveStartPoint(contourCrv)

endpt=rhino.CurveEndPoint(contourCrv)

pt1=ptoncrv(contourCrv,k1)

pt2=ptoncrv(contourCrv,k2)

pt3=ptoncrv(contourCrv,k3)

pt33=rhino.CurveClosestPoint(contourCrv2,pt3)

pt333=rhino.EvaluateCurve(contourCrv2,pt33)

pt4=ptoncrv(contourCrv,k4)

pt44=rhino.CurveClosestPoint(contourCrv2,pt4)

pt444=rhino.EvaluateCurve(contourCrv2,pt44)

pt5=ptoncrv(contourCrv,k5)

pt55=rhino.CurveClosestPoint(contourCrv2,pt5)

pt555=rhino.EvaluateCurve(contourCrv2,pt55)

pt6=ptoncrv(contourCrv,k6)

pt66=rhino.CurveClosestPoint(contourCrv2,pt6)

pt666=rhino.EvaluateCurve(contourCrv2,pt66)

pt7=ptoncrv(contourCrv,k7)

pt8=ptoncrv(contourCrv,k8)

blendCrv=rhino.AddCurve(array(startpt,pt1,pt2,pt333,pt444,pt555,pt666,pt7,pt8,endpt))

End Function

Function PtonCrv(strCrv,k)

Dim Crvdom,ratio

Crvdom=rhino.CurveDomain(strCrv)

ratio=Crvdom(0)+k*(Crvdom(1)-Crvdom(0))

PtonCrv=rhino.EvaluateCurve(strCrv,ratio)

End Function

 

Search Site




archi·o·logics survey

I am interested in: