Rhino3DE
develop
design
educate
v3 plugins
v3 vbscript
v2 vbscript
tutorial
color match
convert curve equichordal
history hide
mesh mapper
open with V4
sel pts on crv
whats that
errors
pure code
clean code
     
 

What does this Code mean?

 

 

 

 

arrPoint1 = Rhino.GetPoint("First point")

 

 

arrPoint1 is a variable that stores data. It could have any name, but it's a good idea to give it a name that tells us what it contains. The "arr" only wants to tells us, that this variable contains an array - in this case three values, that are needed to define a point in 3D space (x,y,z).

   
 

 

arrPoint2 = Rhino.GetPoint("Second point")

 

 

Rhino.GetPoint is one of all those wondeful methods that Dale Fugier implemented for the scripters. This method requires interaction. The script waits until the user pickes a point in the Rhino application window. The Rhino.GetPoint method is followed by an optional parameter ("Second point")This is simply a string that is prompted to the command line, so the user knows to pick a point. The entered point (array) will then be assigned (=) to the arrPoint2 variable.

   
 

 

dblDistance = Rhino.Distance(arrPoint1, arrPoint2)

 

 

Now the script calculates the distance between the entered points (arrPoint1, arrPoint2). There is nothing to see in the Rhino window during this step. It only happens inside the script and the result will be stored in dblDistance. "dbl" should only show us that this variable contains a floating point value with double precision.

There are other types of variables like "int" which means an integer (whole numbers) or "str" which means a simple text string.

   
 

 

Rhino.Print "Distance: " & CStr(dblDistance)

 

 

Rhino.Print is a scripting method to print a string (text) in the command history. Strings are written between double quotes "Distance" otherwise the script engine would expect that you mean the content of the Distance variable. Well the content of our dblDistance variable we also want and so we add it with the "&". Ok there is also this CStr(). It simply converts the numerical value in dblDistance into a string.

Instead of Rhino.Print we could also use a MessageBox to show the result of the script. Then the last line in our script should look like this:

   
 

 

MsgBox "Distance: " & CStr(dblDistance)

 

© 3DE < ^ >