Categories
Cursos

SunSurfaceSplit

 

Os subimos el script para utilizar la inclinación del sol como parámetro que explicamos en la última clase

 

 

‘Script written by Miguel Mesa

‘Script copyrighted by {LAC}

‘Script version martes, 26 de agosto de 2008 3:18:07

 

Call SunSurfaceSplit()

Sub SunSurfaceSplit()

Dim strSurfaceID : strSurfaceID = Rhino.GetObject(“Selecciona una Superficie”, 8, True, True)

Dim strDirSolID: strDirSolID = Rhino.GetObject(“Selecciona Dirección del Sol”, 4, True, True)

If IsNull (strSurfaceID) Then Exit Sub

If IsNull (strDirSolID) Then Exit Sub

Dim intCount1 : intCount1 = Rhino.GetInteger(“¿Número de Frames en u?”, 10, 2, 2000)

If IsNull(inCount) Then Exit Sub

Dim intCount2 : intCount2 = Rhino.GetInteger(“¿Número de Frames en v?”, 10, 2, 2000)

Dim uDomain : uDomain = Rhino.SurfaceDomain(strSurfaceID, 0)

Dim vDomain : vDomain = Rhino.SurfaceDomain(strSurfaceID, 1)

Dim uStep : uStep = (uDomain(1) – uDomain(0))/intCount1

Dim vStep : vStep = (vDomain(1) – vDomain(0))/intCount2

Dim u, v

Dim pt

Dim srfFrame

Call Rhino.EnableRedraw(False)

For u = uDomain(0) To uDomain(1) Step uStep

For v = vDomain(0) To vDomain(1) Step vStep

pt = Rhino.EvaluateSurface(strSurfaceID, Array(u, v))

If Rhino.Distance(pt, Rhino.BrepClosestPoint(strSurfaceID, pt)(0)) < 0.1 Then

srfFrame = Rhino.SurfaceFrame(strSurfaceID, Array(u, v))

Dim VectorPerp : VectorPerp = Rhino.SurfaceNormal(strSurfaceID, Array(u, v))

VectorPerp = Rhino.VectorScale(VectorPerp, 10)

Dim ExtrudePath : ExtrudePath = Rhino.AddLine(pt,Rhino.VectorAdd(pt,VectorPerp))

Dim A : A = Rhino.CurveStartPoint(strDirSolID)

Dim B : B = Rhino.CurveEndPoint(strDirSolID)

Dim C : C = Pt

Dim D : D = Rhino.CurveEndPoint(ExtrudePath)

‘Dim VSol : VSol = Rhino.VectorCreate(A, B)

Dim dblAngulo : dblAngulo = Rhino.Angle2(array(A,B), array(C,D))

 

 

Dim Circle : Circle = Rhino.AddCircle(srfFrame,0.01*dblAngulo(0))

Dim Cilindro : Cilindro = Rhino.ExtrudeCurve(Circle,ExtrudePath)

Dim CilindroMoved : CilindroMoved = Rhino.MoveObject(Cilindro, pt, Rhino.VectorSubtract(pt, Rhino.VectorDivide(VectorPerp, 2)))

 

Dim SplitBrep : SplitBrep = Rhino.SplitBrep(strSurfaceID, CilindroMoved, True)

If Not IsNull (SplitBrep(0)) Then

strSurfaceID = SplitBrep(0)

Call Rhino.DeleteObject(SplitBrep(1))

End If

Call Rhino.DeleteObject(CilindroMoved)

Call Rhino.DeleteObject(Circle)

Call Rhino.DeleteObject(ExtrudePath)

End If

Next

Next

Call Rhino.EnableRedraw(True)

End Sub