Modelo en Rhinoceros con Scrip a partir de una superficie.
Se selecciona la superficie sobre la que queremos actuar y se introduce el numero de elementos en los que queremos que se divida la superficie en las dos direcciones. El Scrip generará una serie de curvas de distinto grado a partir de 3 puntos de las superficie. Se uniran mediante loft para crear los componentes. Una vez utilizadas las curvas se eliminarán para limpiar el modelo.
*Nota: Para acceder al código leer información adicional.
Option Explicit
'Script written by <Nymeria>
'Script copyrighted by
'Script version viernes, 27 de abril de 2012 19:00:05
Call Main()
Sub Main()
Dim strSrf
strSrf = Rhino.GetObject ("select your surface",8)
Dim divU, divV
divU = Rhino.GetInteger ("enter divisions un U direction",4,4,20)
divV = Rhino.GetInteger ("enter divisions un V direction",4,4,20)
'Calculate domains
Dim arrDomU, arrDomV
arrDomU = Rhino.SurfaceDomain(strSrf,0)
arrDomV = Rhino.SurfaceDomain(strSrf,1)
'Calculate length domain
Dim lenU, lenV
lenU = arrDomU (1) - arrDomU (0)
lenV = arrDomV (1) - arrDomV (0)
'Calculete stepSize
Dim StepU, StepV
StepU = lenU/divU
StepV = lenV/divV
Rhino.EnableRedraw False
Dim i,j,b
b=2
For i = arrDomU (0) To arrDomU (1) Step StepU
For j = arrDomV (0) To arrDomV (1) Step StepV
If i < arrDomU (1) And j < arrDomV (1) Then
Dim arrPt1, arrPt2, arrPt3, arrPt4, arrPt5, arrPt6
Dim arrN1, arrN2, arrN3, arrN4, arrN5, arrN6
Dim arrN11, arrN12, arrN13, arrN14, arrN15, arrN16
Dim arrPtCenter, arrScalePoly, arrScaleCurve,arrScalePolyN,arrScaleCurve2,arrScaleCurveP
Dim strPoly1, strPoly2, strPoly3, strPoly4
Dim strPoly1N, strPoly2N, strPoly3N, strPoly4N
Dim strPoly11N, strPoly12N, strPoly13N, strPoly14N
Dim strCrv1, strCrv2, strCrv3, strCrv4
Dim strCrv1N, strCrv2N, strCrv3N, strCrv4N
Dim strCrv11N, strCrv12N, strCrv13N, strCrv14N
Dim scaleFactor, scaleFactor2
Dim strSrf1, strSrf2, strCrv11P, strCrv12P,strCrv13P,strCrv14P
Dim x,y,a,z
arrScalePoly = array (0.7,1,0.8)
arrScaleCurve = array (0.62,0.8,0.55)
arrScalePolyN = array (1,1,1)
arrScaleCurveP = array (1,0.8,0.6)
arrPt1 = Rhino.EvaluateSurface (strSrf, array(i,j))
arrPt2 = Rhino.EvaluateSurface (strSrf, array(i+(stepU*0.5),j+(stepV*0.5)))
arrPt3 = Rhino.EvaluateSurface (strSrf, array(i+stepU,j))
arrPt4 = Rhino.EvaluateSurface (strSrf, array(i+stepU,j+stepV))
arrPt5 = Rhino.EvaluateSurface (strSrf, array(i,j+stepV))
arrPt6 = Rhino.EvaluateSurface (strSrf, array(i+(stepU*1.5),j+(stepV*0.5)))
arrN1 = Rhino.SurfaceNormal (strSrf, array(i,j))
arrN2 = Rhino.SurfaceNormal (strSrf, array(i+(stepU*0.5),j+(stepV*0.5)))
arrN3 = Rhino.SurfaceNormal (strSrf, array(i+stepU,j))
arrN4 = Rhino.SurfaceNormal (strSrf, array(i+stepU,j+stepV))
arrN5 = Rhino.SurfaceNormal (strSrf, array(i,j+stepV))
arrN6 = Rhino.SurfaceNormal (strSrf, array(i+(stepU*1.5),j+(stepV*0.5)))
arrN11 = Rhino.SurfaceNormal (strSrf, array(i,j))
arrN12 = Rhino.SurfaceNormal (strSrf, array(i+(stepU*0.5),j+(stepV*0.5)))
arrN13 = Rhino.SurfaceNormal (strSrf, array(i+stepU,j))
arrN14 = Rhino.SurfaceNormal (strSrf, array(i+stepU,j+stepV))
arrN15 = Rhino.SurfaceNormal (strSrf, array(i,j+stepV))
arrN16 = Rhino.SurfaceNormal (strSrf, array(i+(stepU*1.5),j+(stepV*0.5)))
arrN1 = Rhino.VectorUnitize (arrN1)
arrN2 = Rhino.VectorUnitize (arrN2)
arrN3 = Rhino.VectorUnitize (arrN3)
arrN4 = Rhino.VectorUnitize (arrN4)
arrN5 = Rhino.VectorUnitize (arrN5)
arrN6 = Rhino.VectorUnitize (arrN6)
arrN11 = Rhino.VectorUnitize (arrN11)
arrN12 = Rhino.VectorUnitize (arrN12)
arrN13 = Rhino.VectorUnitize (arrN13)
arrN14 = Rhino.VectorUnitize (arrN14)
arrN15 = Rhino.VectorUnitize (arrN15)
arrN16 = Rhino.VectorUnitize (arrN16)
scaleFactor = 2
scaleFactor2 = 1
arrN1 = Rhino.VectorScale (arrN1, scaleFactor)
arrN2 = Rhino.VectorScale (arrN2, scaleFactor)
arrN3 = Rhino.VectorScale (arrN3, scaleFactor)
arrN4 = Rhino.VectorScale (arrN4, scaleFactor)
arrN5 = Rhino.VectorScale (arrN5, scaleFactor)
arrN6 = Rhino.VectorScale (arrN6, scaleFactor)
arrN11 = Rhino.VectorScale (arrN11, scaleFactor2)
arrN12 = Rhino.VectorScale (arrN12, scaleFactor2)
arrN13 = Rhino.VectorScale (arrN13, scaleFactor2)
arrN14 = Rhino.VectorScale (arrN14, scaleFactor2)
arrN15 = Rhino.VectorScale (arrN15, scaleFactor2)
arrN16 = Rhino.VectorScale (arrN16, scaleFactor2)
arrN1 = Rhino.VectorAdd (arrN1,arrPt1)
arrN2 = Rhino.VectorAdd (arrN2,arrPt2)
arrN3 = Rhino.VectorAdd (arrN3,arrPt3)
arrN4 = Rhino.VectorAdd (arrN4,arrPt4)
arrN5 = Rhino.VectorAdd (arrN5,arrPt5)
arrN6 = Rhino.VectorAdd (arrN6,arrPt6)
arrN11 = Rhino.VectorAdd (arrN11,arrPt1)
arrN12 = Rhino.VectorAdd (arrN12,arrPt2)
arrN13 = Rhino.VectorAdd (arrN13,arrPt3)
arrN14 = Rhino.VectorAdd (arrN14,arrPt4)
arrN15 = Rhino.VectorAdd (arrN15,arrPt5)
arrN16 = Rhino.VectorAdd (arrN16,arrPt6)
strPoly1 = Rhino.AddCurve (array (arrPt1, arrPt2, arrPt3, arrPt1),b)
strPoly1N = Rhino.AddCurve (array (arrN1, arrN2, arrN3, arrN1),b)
strPoly11N = Rhino.AddCurve (array (arrN11, arrN12, arrN13, arrN11),b)
arrPtCenter = Rhino.EvaluateSurface (strSrf, array(i+(stepU*0.5),j+(stepV/6)))
strCrv1 = Rhino.AddCurve (array (arrPt1, arrPt2, arrPt3, arrPt1))
strCrv1N = Rhino.AddCurve (array (arrN1, arrN2, arrN3, arrN1))
strCrv11P = Rhino.AddCurve (array (arrN11, arrN12, arrN13, arrN11))
Rhino.ScaleObject strPoly1, arrPtCenter, arrScalePoly
Rhino.ScaleObject strPoly1N, arrPtCenter, arrScalePoly
Rhino.ScaleObject strCrv1, arrPtCenter, arrScaleCurve
Rhino.ScaleObject strCrv1N, arrPtCenter, arrScaleCurve
Rhino.ScaleObject strPoly11N, arrPtCenter, arrScalePolyN
Rhino.ScaleObject strCrv11P, arrPtCenter, arrScaleCurveP
strSrf1 = Rhino.AddLoftSrf (array (strPoly1,strPoly11N, strPoly1N, strCrv1N, strCrv1))
strSrf2 = customloft (array (strPoly1, strCrv1))
a = array(strPoly1 ,strPoly1N,strPoly11N,strCrv1,strCrv1N,strCrv11P)
Rhino.DeleteObjects a
strPoly2 = Rhino.AddCurve (array (arrPt2, arrPt4, arrPt5, arrPt2),b)
strPoly2N = Rhino.AddCurve (array (arrN2, arrN4, arrN5, arrN2),b)
strPoly12N = Rhino.AddCurve (array (arrN12, arrN14, arrN15, arrN12),b)
arrPtCenter = Rhino.EvaluateSurface (strSrf, array(i+(stepU*0.5),j+(5*stepV/6)))
strCrv2 = Rhino.AddCurve (array (arrPt2, arrPt4, arrPt5, arrPt2))
strCrv2N = Rhino.AddCurve (array (arrN2, arrN4, arrN5, arrN2))
strCrv12P = Rhino.AddCurve (array (arrN12, arrN14, arrN15, arrN12))
Rhino.ScaleObject strPoly2, arrPtCenter, arrScalePoly
Rhino.ScaleObject strPoly2N, arrPtCenter, arrScalePoly
Rhino.ScaleObject strCrv2, arrPtCenter, arrScaleCurve
Rhino.ScaleObject strCrv2N, arrPtCenter, arrScaleCurve
Rhino.ScaleObject strPoly12N, arrPtCenter, arrScalePolyN
Rhino.ScaleObject strCrv12P, arrPtCenter, arrScaleCurveP
strSrf1 = Rhino.AddLoftSrf (array (strPoly2,strPoly12N, strPoly2N, strCrv2N, strCrv2))
strSrf2 = customloft (array (strPoly2, strCrv2))
z = array(strPoly2 ,strPoly2N,strPoly12N,strCrv2,strCrv2N,strCrv12P)
Rhino.DeleteObjects z
If i < arrDomU (1) - StepU Then
strPoly3 = Rhino.AddCurve (array (arrPt2, arrPt3, arrPt6, arrPt2),b)
strPoly3N = Rhino.AddCurve (array (arrN2, arrN3, arrN6, arrN2),b)
strPoly13N = Rhino.AddCurve (array (arrN12, arrN13, arrN16, arrN12),b)
arrPtCenter = Rhino.EvaluateSurface (strSrf, array(i+stepU,j+(stepV/3)))
strCrv3 = Rhino.AddCurve (array (arrPt2, arrPt3, arrPt6, arrPt2))
strCrv3N = Rhino.AddCurve (array (arrN2, arrN3, arrN6, arrN2))
strCrv13P = Rhino.AddCurve (array (arrN12, arrN13, arrN16, arrN12))
Rhino.ScaleObject strPoly3, arrPtCenter, arrScalePoly
Rhino.ScaleObject strPoly3N, arrPtCenter, arrScalePoly
Rhino.ScaleObject strCrv3, arrPtCenter, arrScaleCurve
Rhino.ScaleObject strCrv3N, arrPtCenter, arrScaleCurve
Rhino.ScaleObject strPoly13N, arrPtCenter, arrScalePolyN
Rhino.ScaleObject strCrv13P, arrPtCenter, arrScaleCurveP
strSrf1 = Rhino.AddLoftSrf (array (strPoly3,strPoly13N, strPoly3N, strCrv3N, strCrv3))
strSrf2 = customloft (array (strPoly3, strCrv3))
y = array(strPoly3 ,strPoly3N,strPoly13N,strCrv3,strCrv3N)
Rhino.DeleteObjects y
strPoly4 = Rhino.AddCurve (array (arrPt2, arrPt4, arrPt6, arrPt2),b)
strPoly4N = Rhino.AddCurve (array (arrN2, arrN4, arrN6, arrN2),b)
strPoly14N = Rhino.AddCurve (array (arrN12, arrN14, arrN16, arrN12),b)
arrPtCenter = Rhino.EvaluateSurface (strSrf, array(i+stepU,j+(2*stepV/3)))
strCrv4 = Rhino.AddCurve (array (arrPt2, arrPt4, arrPt6, arrPt2))
strCrv4N = Rhino.AddCurve (array (arrN2, arrN4, arrN6, arrN2))
strCrv14P = Rhino.AddCurve (array (arrN12, arrN14, arrN16, arrN12))
Rhino.ScaleObject strPoly4, arrPtCenter, arrScalePoly
Rhino.ScaleObject strPoly4N, arrPtCenter, arrScalePoly
Rhino.ScaleObject strCrv4, arrPtCenter, arrScaleCurve
Rhino.ScaleObject strCrv4N, arrPtCenter, arrScaleCurve
Rhino.ScaleObject strPoly14N, arrPtCenter, arrScalePolyN
Rhino.ScaleObject strCrv14P, arrPtCenter, arrScaleCurveP
strSrf1 = Rhino.AddLoftSrf (array (strPoly4,strPoly14N, strPoly4N, strCrv4N,strCrv4))
strSrf2 = customloft (array (strPoly4, strCrv4))
x = array(strPoly4 ,strPoly4N,strPoly14N,strCrv4,strCrv4N)
Rhino.DeleteObjects x
End If
End If
Next
Next
Rhino.EnableRedraw True
End Sub
Function customloft (arrCrvs)
Rhino.SelectObjects arrCrvs
Rhino.Command"-_loft _enter _enter",0
Rhino.UnselectAllObjects
End Function
No hay comentarios:
Publicar un comentario