Описание слайда:
' Copy and paste this code in your RhinoScript Editor (Tools RhinoScript Edit…)
' Copy and paste this code in your RhinoScript Editor (Tools RhinoScript Edit…)
' This is a basic script to draw a curve with fixed coordinates (Not very useful, but a good starting point)
Option Explicit ' nevermind this, just make sure that your scripts always start with it
DrawCurve ' this tells the program what subroutine to run
Sub DrawCurve ' this is the code to run when “DrawCurve” is called above
Call Rhino.enableRedraw(False) ' nevermind this, it speeds up the execution of the code
Dim controlpoints(3), i ' controlpoints is an array of 3-D points (see next slide)
For i=0 To 50
controlpoints(0) = Array(0,0,0) ' x = 0, y = 0, z = 0
controlpoints(1) = Array(randomBetween(-5,5),randomBetween(-5,5),0)
controlpoints(2) = Array(randomBetween(-10,10),randomBetween(-10,10),15)
controlpoints(3) = Array(randomBetween(-10,10),randomBetween(-10,10),20)
Rhino.AddCurve controlpoints, 3 ' this draws the curve
Rhino.AddSphere controlpoints(1), 0.25 ' this draws a small sphere at second point
Rhino.AddSphere controlpoints(2), 0.25 ' this draws a big sphere at third point
Rhino.AddSphere controlpoints(3), 0.75 ' this draws a big sphere at third point
Next
Call Rhino.enableRedraw(True) ' nevermind this, it refreshes the screen
Rhino.ZoomExtents ' and this adjusts the zoom level
End Sub ' this is the end of the "DrawCurve" subroutine
Function randomBetween(min,max) ' this is the code to generate random numbers between limits
randomBetween = Rnd*(max-min)+min ' returns a random number between the limits specified
End Function ' end of the randomness function