'///////////////////////////////////////////////////////////////////////////////////////////// '// Soluciones de Diseño Computacional :: Lima :: Peru :: Enero 2008 04.02.2008 '// Rhinoscripting Workshop. http://www.espaciosdigitales.org/lima/1/ '// Script developed by Juan Pablo Acosta, Cecilia Antunez de Mayolo, Rodrigo Barreto, Mónica Freund '// Instructores: Kenfield Griffith, Daniel Cardoso, Pablo C. Herrera '// Coordinacion General: Pablo C. Herrera pablo@espaciosdigitales.org '///////////////////////////////////////////////////////////////////////////////////////////// 'Start program call dynamicSurface '=================DYNAMIC SURFACE FUNCTION 'function updates the value of a surface 'creating a new surface as a nurb_like 'behavior================================== function dynamicSurface() dim surface dim points dim startTime, EndTime dim segDivision segDivision = 10 Redim numberOfPoints(1) 'NUMBER OF POINTS IN BOTH U and V directions numberOfPoints(0) = segDivision + 1 'U numberOfPoints(1) = segDivision + 1 'V 'Get Surface from user surface = Rhino.GetObject("Dame un superficie",8) points = traverseSurface(surface,segDivision) 'Create variable for 1D array dim numPoints numPoints = ((segDivision+1) * (segDivision+1))-1 redim pts(numPoints) dim counter dim flag counter = 0 'CREATE 1D array of points for i = 0 to segDivision for j = 0 to segDivision 'Change Z value of random point in j direction if j = int(rnd()*segDivision) then points(i,j)(2) = points(i,j)(2) + rnd()*12 end if 'Change Z value of random point in i direction ONLY IN CERTAIN POINTS 'random variable for deciding whether or not to change point flag = Int(Rnd()) if flag = 0 Then if i = int(rnd()*segDivision) then points(i,j)(2) = points(i,j)(2) - rnd()*12 redim p(2) p(0) = points(i,j)(0) p(1) = points(i,j)(1) p(2) = 10 Call drawRings(p) 'Call Thick end if else Rhino.Print "Punto no cambiado" end if 'Call drawRings(points(i,j)) Rhino.Print counter pts(counter) = points(i,j) counter = counter + 1 next next 'Delete old surface Rhino.DeleteObject surface 'Create new surface using manipulated points surface = Rhino.AddSrfControlPtGrid (numberOfPoints, pts) Call Proyectar(surface) Call Thick Rhino.DeleteObject(surface) end function '==============TRAVERSE FUNCTION================= 'function takes a surface and divisions and returns 'a set of points on the surface to the function that 'called it '================================================ function traverseSurface(srf, segDivision) dim i,j dim uDomain, vDomain redim ptParam(1) dim point 'Create a container (array) for all points redim allPoints(segDivision, segDivision) Rhino.Print srf 'Rhino default function gets the surface Domain parameters uDomain = Rhino.SurfaceDomain(srf, 0) vDomain = Rhino.SurfaceDomain(srf, 1) 'Loop to the extent of segment count populating 'the surface with points for i = 0 to segDivision for j = 0 to segDivision 'get U,V parameters for point ptParam(0) = i*(uDomain(0)+uDomain(1))/segDivision ptParam(1) = j*(vDomain(0)+vDomain(1))/segDivision 'locate the point on the surface point = Rhino.EvaluateSurface(srf, ptParam) 'add the point to the scene 'call Rhino.addPoint(point) 'Place point in container as created allPoints(i,j) = point next next 'Return points to control function traverseSurface = allPoints end function '================================================================================ Function drawRings(pt) Dim radioInicial : radioInicial = 1 Dim variacion : variacion = 2 Dim cantidadDeAnillos : cantidadDeAnillos = 8 For e = 0 To cantidadDeAnillos 'Rhino.Print radioInicial^2 Rhino.AddCircle pt, (radioInicial * (e^2)/10) Next End Function '============================================================================================= Function Thick Dim arraylines Dim thickness: thickness = 0.08 arraylines=Rhino.ObjectsByType (4, vbFalse) For i=0 To UBound(arraylines) Rhino.SelectObject (arraylines(i)) Rhino.command "_pipe _thick=no _cap=round " & thickness & " _enter" & " _enter" & " _enter" Rhino.UnselectObject(arraylines(i)) Next Rhino.DeleteObjects(arraylines) End Function '====================================================================================== Function Proyectar (ASur) Dim curveAll curveAll= Rhino.ObjectsByType(4) For i=0 To UBound(curveAll) Rhino.SelectObject ASur Rhino.SelectObject curveAll(i) Rhino.Command "_Project " & "_enter" Rhino.UnselectAllObjects() Next Rhino.DeleteObjects(curveAll) End Function