SlideShare une entreprise Scribd logo
1  sur  117
Télécharger pour lire hors ligne
SCRIPTING	IN	RHINO
KAUST		‐ April,	2011
Geometric Modeling and Scientific Visualization CenterGeometric	Modeling	and	Scientific	Visualization	Center
Khaled	Mohamed	Ahmed	Abd	El	Gawad
www.khaledarch.comwww.khaledarch.com
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Outline
 Introduction
 VBScript Essentials
 Operators and functionsp
 Conditional Execution/Branching
 Arrays
 Surface and Polysurface MethodsSurface and Polysurface Methods
 Show Cases
 Grasshopper Overview
 Useful Resources
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Useful Resources
Introduction
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
What	We	Can	Do	Using	RhinoScript?
Computational Design Solution ‐ IAP Course
http://www.kaschaandjohn.com/rhinoscripting/
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
What	We	Can	Do	Using	RhinoScript?
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Computational Design Solution ‐ IAP Course http://www.kaschaandjohn.com/rhinoscripting/
What	We	Can	Do	Using	RhinoScript?
Computational Design Solution ‐ IAP Course
http://www.kaschaandjohn.com/rhinoscripting/
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
What	We	Can	Do	Using	RhinoScript?
http://www.rhinoscript.org/gallery/2
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Scripting	vs.	Programming	Languages.
 These days, the line between a scripting language and 
i l i bl da programming language is blurred. 
 Scripting Languages:
 Run Inside other programsRun Inside other programs
 Are not compiled.
 A t d t it Are easy to use and easy to write.
 Scripting languages are used to build complex 
software.
 Scripting languages are so efficient
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
p g g g
Macros
 Rhinoceros is based on
a command linea command‐line 
interface.
 A macro is a prerecorded list of orders for Rhino to 
executeexecute.
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Macros
 Example:
A 
(0, 0, 0)
B
(10, 0, 0)
Open100 Add line Save Files
Rhino Files
 Macros allow you to automate tasks you would 
normally do by hand but not by brain. 
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Scripts
 Scripts are text files which are interpreted one line at 
ia time.
 Scripts have control over which line is executed next.
 We must familiarize ourselves with the language rules 
f VBS ript b f fl t lof VBScript before we can use flow control.
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
How	to	Run	a	Script?
 We could store scripts as external text files and have 
Rhino load them whenever we want to run themRhino load them whenever we want to run them
 We could also use Rhino's in‐build script editor.
 _EditScript  Command line_ p
 Tools  Rhinoscript  Edit
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
How	to	Run	a	Script?
The Script Window will 
show upshow up
Then we can write 
i t i t thour script into the 
Script Editor window 
th li k tthen click execute
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
How	to	Run	a	Script?
 Or we can embed scripts in toolbar buttons, which 
makes it very hard to edit them but much easier tomakes it very hard to edit them, but much easier to 
distribute them.
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
VBScript	Essentials
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Language	origin
 VBScript is a member of the BASIC language family.
 The language was designed to be easy for humans to 
understand.
 BASIC stands for Beginner’s All‐purpose Symbolic 
Instruction Code.Instruction Code.
 Rhino Scripting syntax rules are basically the same as Rhino Scripting syntax rules are basically the same as 
Visual BASIC.
3/12/2014 16
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Flow	Control
 We use it to skip certain lines of code or 
 To execute others more than once. 
 To jump to different lines in our script and back again.To jump to different lines in our script and back again.
 You can add conditional statements to your code You can add conditional statements to your code 
which allow you to shield off certain portion
3/12/2014 17
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Variable Data
 From a programmer's point of view, a variable is a 
location in your computer's memory in which you canlocation in your computer s memory in which you can 
store a value and from which you can later retrieve 
that valuethat value.
A visual representation of memory
3/12/2014 18
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
A visual representation of memory
Variable Data
 Whenever we need to store data or perform 
calculations or logic operations we need variables tocalculations or logic operations we need variables to 
remember the results.
33 33..44 datadata
X Y Variable name
3/12/2014 19
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
X Y Variable name
Variable Data
 There are different data types: Integers, doubles, 
Booleans strings and Null variableBooleans, strings, and Null variable.
D bl
Integer
Double
Boolean
Null
St i datadataString datadata
Variable name
3/12/2014 20
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Variable Data: Integers and Doubles
 Doubles are numeric variables which can store 
numbers with decimalsnumbers with decimals. 
3/12/2014 21
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Variable Data: Booleans
 Boolean variables can only store two values mostly 
referred to as Yes or No True or Falsereferred to as Yes or No, True or False.
 In VBScript we never write "0" or "1" or "Yes" or "No”
 We always use "True" or "False".
3/12/2014 22
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Variable Data: Strings
 Strings are used to store text. 
 Whenever you add quotes around stuff in VBScript, it 
automatically becomes a String. 
 So if we encapsulate a number in quotes, it will 
become textbecome text
3/12/2014 23
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Variable Data: Strings
 String Assignment and Concatenation
3/12/2014 24
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Variable Data: Strings
 When using  & you can treat numeric variables as 
StringsStrings
3/12/2014 25
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Variable Data: Null Variable
 When a variable has no value, it considered to be null.
 Having a null value is different than having a value of 
0, since 0 is an actual value.
 Whenever we ask Rhino 
a question which might 
not have an answer, we 
need a way for Rhino to 
say "I don't know"
3/12/2014 26
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Using Variables
 Variable Declaration:
 W ll d l i bl i h Di We normally declare a variable using the Dim
keyword.
 We can declare multiple variables using a singleWe can declare multiple variables using a single 
Dim keyword if we comma‐separate them.
3/12/2014 27
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Using Variables
 Variable Names:
 I i d d fi It is recommended to use prefixes.
 Use a 3 character prefix which indicates the type of 
variable
V i bl t P fi E lVariable type Prefix Example
Boolean bln blnSuccess
Integer int intX
Double dbl dblYDouble dbl dblY
String str strfood
3/12/2014 28
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Using Variables
 Variable Assignment:
 B f f i bl Before you can use any of your variables, you must 
first assign them a value.
3/12/2014 29
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Operators	and	Functions
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Operators and Functions
 Th i fi t i th f ll i The previous figure contains the followings:
 Numbers (15, 26, 2.33 and 55)
 Variables (x, y, and z)
 Operators ( =, +, * and /)p ( , , /)
 Functions (Sin, Sqr, Tan and Log)
3/12/2014 31
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Operators in RhinoScript
 Arithmetic Operators
 C i O Concatenation Operators
 Comparison Operators
 Logical and bitwise Operators
3/12/2014 32
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Operators in RhinoScript
 Arithmetic Operators
 C i O Concatenation Operators
 Comparison Operators
 Logical and bitwise Operators
3/12/2014 33
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Operators in RhinoScript
 Operator Precedence
 The acronym PEMDAS or "Please Excuse My Dear  
Aunt Sally" is common. 
 It stands for Parentheses, Exponents, 
Multiplication, Division, Addition, Subtraction.Multiplication, ivision, Addition, Subtraction.
3/12/2014 34
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Operators in RhinoScript
 Operator Precedence
 B d i i f h ld d h Based on previous info how could we code the 
following?
PEMDAS
3/12/2014 35
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Operators in RhinoScript
 Operator Precedence
 B d i i f h ld d h Based on previous info how could we code the 
following?
PEMDAS
Solution:
y = Sqr(x ^ 2 + (x ‐ 1)) / (x ‐ 3) ) + Abs( (2 * x) / (x ^ (0.5 * x)) 
Solution:
3/12/2014 36
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Operators in RhinoScript
 Operator Precedence
 T i lif h i d i To simplify the equation we can spread it out over 
multiple lines of code
y = Sqr(x ^ 2 + (x ‐ 1)) / (x ‐ 3) ) + Abs( (2 * x) / (x ^ (0.5 * x)) 
3/12/2014 37
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Operators in RhinoScript
 Arithmetic Operators
 C i O Concatenation Operators
 Comparison Operators
 Logical and bitwise Operators
3/12/2014 38
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Operators in RhinoScript
 Arithmetic Operators
 C i O Concatenation Operators
 Comparison Operators
 Logical and bitwise Operators
3/12/2014 39
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Operators in RhinoScript
 Arithmetic Operators
 C i O Concatenation Operators
 Comparison Operators
 Logical and bitwise Operators
3/12/2014 40
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Operators in RhinoScript: Logical Operators
 Logical operators mostly work on Booleans.
 Boolean mathematics were developed by George 
Boole (1815‐1864) and today they are at the very core 
of the entire digital industry.
 Boolean algebra provides us with tools to analyze, 
compare and describe sets of data.
M f h B l O N A d Most famous three Boolean Operators are: Not, And, 
and Or.
3/12/2014 41
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Operators in RhinoScript: Logical Operators
 A good way to exercise your own Boolean logic is to 
use Venn‐diagrams. 
 A Venn diagram is a graphical representation of 
Boolean sets where every region contains a (sub) setBoolean sets, where every region contains a (sub) set 
of values that share a common property.
3/12/2014 42
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Operators in RhinoScript: Logical Operators
3/12/2014 43
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Operators in RhinoScript: Logical Operators
3/12/2014 44
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Operators in RhinoScript: Logical Operators
3/12/2014 45
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Operators in RhinoScript: Logical Operators
 Venn diagrams are useful for simple problems, but 
once you start dealing with more than three regions itonce you start dealing with more than three regions it 
becomes a bit opaque. 
 6 i l V di P tt b t t ti l 6‐regional Venn diagram. Pretty, but not very practical
3/12/2014 46
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Functions in RhinoScript
 Microsoft VBScript has 89 built in functions:
 Sin(n) Sine of a number
 Cos(n) Cosine of a numberCos(n) Cosine of a number
 Atn(n) ArcTangent of a number
 Log(n) Natural logarithm of a number larger than 0
 Sqr(n) Square root of any positive numberSqr(n) Square root of any positive number
 Abs(n) Absoluter (positive) value of any number
3/12/2014 47
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Functions in RhinoScript
 Rhino adds over 200 functions called methods:
 Rhino.command (“_Move 0, 0, 0 2, 0, 1”)
 Rhino.UnselectAllobjects()Rhino.UnselectAllobjects()
 Rhino.Selectobject (strCurveID)
 Rhino.Copyobject (strCurveID)
 Rhino.GetObject (“Select an object”)Rhino.GetObject ( Select an object )
3/12/2014 48
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
What is a Function?
 A function is a closed body of code that executes a 
specific taskspecific task.
 A function is like a black box. 
 It takes in input, 
 does something with it does something with it, 
 and then spits out an answer.
 A function may not take any inputs at all or it may not 
return anything at all.return anything at all.
3/12/2014 49
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Function Example
3/12/2014 50
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Why Would We Need Functions?
 we can write it as a single function and access the 
same function again and again as many times as it issame function again and again as many times as it is 
required.
 We can avoid writing redundant code of some 
instructions again and again.
 Programs with using functions are compact & easy to 
understand.understand.
 Testing and correcting errors is much easier.
3/12/2014 51
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Why Would We Need Functions?
 We can understand the flow of program, and its code 
easily since the readability is enhanced while using theeasily since the readability is enhanced while using the 
functions.
 A single function written in a program can also be 
used in other programs also.
3/12/2014 52
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Script File Structure
 Every script must implement a certain structure which 
tells the interpreter what's whattells the interpreter what s what.
3/12/2014 53
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Script File Structure
 Every script must implement a certain structure which 
tells the interpreter what's whattells the interpreter what s what.
3/12/2014 54
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Script File Structure
 Option Explicit:
 It is optional, but it is highly 
recommended.
 If you use it, you have to define all 
your variables before you can useyour variables before you can use 
them. 
 If you don’t use it your variables If you don t use it, your variables 
will be declared for you by the 
compilercompiler. 
3/12/2014 55
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Script File Structure
 Option Explicit:
 It may also contains a set of 
comments. 
 Comments are blocks of text in the 
script which are ignored by thescript which are ignored by the 
compiler and the interpreter. 
 comments are used to add comments are used to add 
explanations to a file, or to disable 
certain lines of codecertain lines of code. 
 Comments are always preceded by 
3/12/2014 56
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
an apostrophe. 
Script File Structure
 Global Variables:
 They are optional.
 Typically you do not need globalTypically you do not need global 
variables and you're usually better 
off without them.off without them.
3/12/2014 57
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Script File Structure
 The Main Function
 Every script requires at least one 
function contains the main code of 
the script. 
 it can place calls to any number ofit can place calls to any number of 
other functions 
 It delineates the extents of the It delineates the extents of the 
script. 
 The script starts running as soon as 
this function is called and it stops 
3/12/2014 58
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
when the function completes. 
A Simple Function Example
3/12/2014 59
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
A Simple Function Example
3/12/2014 60
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Conditional	Execution/Branching
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Conditional execution or Branching
 IF….Then Statement
 Select case
 LoopingLooping
 Conditional loops
 Incremental loops
 Nested LoopsNested Loops
3/12/2014 62
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
IF….Then Statement 
 If we have three different situations:
1. If the object is a curve, delete it.
2. If the object is a short curve, delete it.2. If the object is a short curve, delete it.
3. If the object is a short curve, delete it, otherwise 
it t th “ ” lmove it to the “curves” layer.
How would this be implemented using RhinoScript?
3/12/2014 63
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
IF….Then Statement 
 If we have three different situations:
1. If the object is a curve, delete it.
2. If the object is a short curve, delete it.2. If the object is a short curve, delete it.
3. If the object is a short curve, delete it, otherwise 
it t th “ ” lmove it to the “curves” layer.
How would this be implemented using RhinoScript?
This is so easy. We just need to learn how 
conditional syntax works.
3/12/2014 64
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
y
IF….Then Statement 
1. If the object is a curve, delete it.
2. If the object is a short curve, delete it.
3/12/2014 65
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
IF….Then Statement 
3. If the object is a short curve, delete it, otherwise 
move it to the “curves” layermove it to the  curves  layer.
3/12/2014 66
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Select … Case
 We use Select…Case when we want to check the  
equalityequality.
3/12/2014 67
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Select … Case (Sort objects based on type)
An Integer to store the An Integer to store the 
Rhi ObjRhi Obj T dT dRhino ObjectRhino Object‐‐Type codeType code
3/12/2014 68
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Select … Case (Sort objects based on type)
This means the object This means the object 
does not exist; abortdoes not exist; abort
3/12/2014 69
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Select … Case (Sort objects based on type)
A String to store a layer A String to store a layer 
namename
3/12/2014 70
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Select … Case (Sort objects based on type)
Compare the actual Compare the actual 
d h hd h htype code with the type code with the 
preset onespreset ones
3/12/2014 71
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Select … Case (Sort objects based on type)
Points andPoints and PointCloudPointCloudPoints and Points and PointCloudPointCloud
objectsobjects
3/12/2014 72
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Select … Case (Sort objects based on type)
CurvesCurves
3/12/2014 73
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Select … Case (Sort objects based on type)
Surfaces and Surfaces and 
PolySurfacesPolySurfacesPolySurfacesPolySurfaces
3/12/2014 74
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Select … Case (Sort objects based on type)
MeshesMeshes
3/12/2014 75
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Select … Case (Sort objects based on type)
LightsLights
3/12/2014 76
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Select … Case (Sort objects based on type)
Annotations and Annotations and 
TextDotsTextDots
3/12/2014 77
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Select … Case (Sort objects based on type)
BlocksBlocks
3/12/2014 78
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Select … Case (Sort objects based on type)
Any other objects; Any other objects; 
AbortAbort
3/12/2014 79
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Select … Case (Sort objects based on type)
If h lIf h lIf the layer we are If the layer we are 
about to assign does about to assign does 
not yet existnot yet existnot yet exist…not yet exist…
3/12/2014 80
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Select … Case (Sort objects based on type)
Create itCreate it
3/12/2014 81
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Select … Case (Sort objects based on type)
Assign the object to the Assign the object to the 
layerlayer
3/12/2014 82
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Looping
 Executing certain lines of code more than once is 
called looping in programming slangcalled looping in programming slang.
 The two most important syntax for loops:
 Conditional Loops (Do loop Do While loop Conditional Loops  (Do…loop,   Do While…loop,  
Do Until…loop)
 Incremental loops (For...Next)
3/12/2014 83
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Conditional loops
 We use it when we do not know how many iterations 
we will need in advancewe will need in advance. 
 This type is called a Do…Loop.
3/12/2014 84
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Conditional loops: Do…Loop
 This example script contains an endless Do…Loop
which can only be cancelled by the user pressingwhich can only be cancelled by the user pressing 
(and holding) escape.
3/12/2014 85
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Conditional loops: Do…Loop
 1 & 2: Option Explicit declaration and comments 
about who's who and what's whatabout who s who and what s what
 4: Main Function call
3/12/2014 86
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Conditional loops: Do…Loop
 5: Main function declaration
 6 W d l i bl hi h i bl f t i 6: We declare a variable which is capable of storing a 
Rhino object ID
3/12/2014 87
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Conditional loops: Do…Loop
 7: We create a new Rhino Text object
Rhi AddT t ( t T t P i t [ dblH i ht [ t F t [Rhino.AddText (strText, arrPoint [, dblHeight [, strFont [, 
intStyle]]])
3/12/2014 88
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Conditional loops: Do…Loop
 8: Just in case the text object hasn't been created we 
need to abort the subroutine in order to prevent anneed to abort the subroutine in order to prevent an 
error later on.
3/12/2014 89
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Conditional loops: Do…Loop
 10: Starting the loop
 11 W d t h th t t d 11: We need to change the text once every second. 
The Rhino.Sleep() method will pause Rhino for the 
specified amo nt of milliseconds
3/12/2014 90
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
specified amount of milliseconds.
Conditional loops: Do…Loop
 12: Here we replace the text in the object with a new 
String representing the current system time.String representing the current system time.
3/12/2014 91
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Conditional loops: Do While…Loop
 This kind of loop syntax will abort the loop when 
S C di i i lSomeCondition is False.
3/12/2014 92
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Conditional loops: Do Until…Loop
 If we want the loop to terminate when a condition 
b i d f l h U ilbecomes True instead of False, we can use the Until 
keyword instead of the While keyword
3/12/2014 93
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Conditional loops: Do…Loop While
 You can be guaranteed that DoSomething will be 
ll d l b i h f ll icalled at least once by using the following syntax:
3/12/2014 94
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Incremental loops
 We use it when the number of iterations is known in 
dadvance.
 The variable i starts out by being equal to A and it is 
incremented by N until it becomes larger than Bincremented by N until it becomes larger than B.
 Once i > B the loop will terminate. 
3/12/2014 95
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Incremental loops
 Example
3/12/2014 96
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Nested Loops
 The following example shows how nested For…Next 
b d di ib istructures can be used to compute distributions:
3/12/2014 97
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Arrays
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Arrays
 An array is a list of variables.
 Arrays start counting at zero.
 The first element of an array is the element withThe first element of an array is the element with 
index 0.
 Arrays are just like other variables in VBScript with Arrays are just like other variables in VBScript with 
the exception that we have to use parenthesis to set 
and retrieve valuesand retrieve values.
3/12/2014 99
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Arrays
3/12/2014 100
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Arrays
 you can also use a shorthand notation in which case 
h h h h blyou have to omit the parenthesis in the variable 
declaration:
 The Array() function in VBScript takes any number of The Array() function in VBScript takes any number of 
variables and turns them into an array.
 You can add as many arguments as you like
3/12/2014 101
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Arrays
 In RhinoScript, coordinates are defined as arrays of 
h b l d hthree numbers. Element 0 corresponds with x, 
element 1 with y and element 2 with z.
3/12/2014 102
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Plane
3/12/2014 103
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Surface	and	Polysurface Methods
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Basic 3D Geometry: Static Creation
 Add Sphere 
 Add Box
 Add Cylinder Add Cylinder
 Add Cone
 Add Torus 
3/12/2014 105
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Basic 3D Geometry: Dynamic Creation
 Add Sphere 
Exercise
 Add Box
 Add Cylinder
Please write a script 
b
Exercise
 Add Cylinder
 Add Cone
to create a Box by 
getting the length, 
width and the height
 Add Torus 
width and the height 
from the user.
Please do the samePlease do the same 
for Cylinder, cone 
and Torus
3/12/2014 106
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Show	Cases
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Example 1: Tree Example
3/12/2014 108
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Example 1: Tree Example
3/12/2014 109
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Example 1: Tree Example
3/12/2014 110
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Example 2: Mesh Generation
3/12/2014 111
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Example 2: Mesh Generation
3/12/2014 112
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Example 2: Mesh Generation
3/12/2014 113
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Grasshopper	Overview
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Useful	Resources
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Useful Resources
 http://wiki.mcneel.com/developer/rhinoscript
Everything about RhinoScript
 http://www.rhino3d.com/developer.htm#vbs
Useful Resources about rhino scripting and 
Grasshopper
 htt // hi i t / t t http://www.rhinoscript.org/start
Important community for RhinoScripting and 
3/12/2014 116
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com
Grasshopper
I	hope	you	have	enjoyed	it	!
Khaled Abd El GawadKhaled	Abd	El	Gawad
www.khaledarch.com
Khaled Abd El Gawad – All rights reserved – www.khaledarch.com

Contenu connexe

Similaire à Kaust rhino workshop 2011

Android's security architecture
Android's security architectureAndroid's security architecture
Android's security architectureOfer Rivlin, CISSP
 
Running your Spring Apps in the Cloud Javaone 2014
Running your Spring Apps in the Cloud Javaone 2014Running your Spring Apps in the Cloud Javaone 2014
Running your Spring Apps in the Cloud Javaone 2014cornelia davis
 
Multimedia document processing using the Weblab platform: AXES project use ca...
Multimedia document processing using the Weblab platform: AXES project use ca...Multimedia document processing using the Weblab platform: AXES project use ca...
Multimedia document processing using the Weblab platform: AXES project use ca...OW2
 
Bridging the gap between business and technology - Behaviour Driven Developme...
Bridging the gap between business and technology - Behaviour Driven Developme...Bridging the gap between business and technology - Behaviour Driven Developme...
Bridging the gap between business and technology - Behaviour Driven Developme...Eugenio Minardi
 
Best practices iOS meetup - pmd
Best practices iOS meetup - pmdBest practices iOS meetup - pmd
Best practices iOS meetup - pmdSuyash Gupta
 
Extending js codemotion warsaw 2016
Extending js codemotion warsaw 2016Extending js codemotion warsaw 2016
Extending js codemotion warsaw 2016Francis Bourre
 
DDD on example of Symfony (SfCampUA14)
DDD on example of Symfony (SfCampUA14)DDD on example of Symfony (SfCampUA14)
DDD on example of Symfony (SfCampUA14)Oleg Zinchenko
 
Creating an all-purpose REST API for Cloud services using OSGi and Sling - C ...
Creating an all-purpose REST API for Cloud services using OSGi and Sling - C ...Creating an all-purpose REST API for Cloud services using OSGi and Sling - C ...
Creating an all-purpose REST API for Cloud services using OSGi and Sling - C ...mfrancis
 
ColdFusion 11 Overview - CFSummit 2013
ColdFusion 11 Overview - CFSummit 2013ColdFusion 11 Overview - CFSummit 2013
ColdFusion 11 Overview - CFSummit 2013Rupesh Kumar
 
How to build Sdk? Best practices
How to build Sdk? Best practicesHow to build Sdk? Best practices
How to build Sdk? Best practicesVitali Pekelis
 
Debugging Drupal - How to Debug your Drupal Application
Debugging Drupal - How to Debug your Drupal ApplicationDebugging Drupal - How to Debug your Drupal Application
Debugging Drupal - How to Debug your Drupal ApplicationZyxware Technologies
 
Bdd Net Frameworks
Bdd Net FrameworksBdd Net Frameworks
Bdd Net Frameworkshdgarcia
 
LDOW2015 - Uduvudu: a Graph-Aware and Adaptive UI Engine for Linked Data
LDOW2015 - Uduvudu: a Graph-Aware and Adaptive UI Engine for Linked DataLDOW2015 - Uduvudu: a Graph-Aware and Adaptive UI Engine for Linked Data
LDOW2015 - Uduvudu: a Graph-Aware and Adaptive UI Engine for Linked DataeXascale Infolab
 
Zend_Tool: Rapid Application Development with Zend Framework
Zend_Tool: Rapid Application Development with Zend FrameworkZend_Tool: Rapid Application Development with Zend Framework
Zend_Tool: Rapid Application Development with Zend FrameworkRalph Schindler
 
Better Code: Concurrency
Better Code: ConcurrencyBetter Code: Concurrency
Better Code: ConcurrencyPlatonov Sergey
 
PHP QA Tools
PHP QA ToolsPHP QA Tools
PHP QA Toolsrjsmelo
 
Structuring An ABAP Report In An Optimal Way
Structuring An ABAP Report In An Optimal WayStructuring An ABAP Report In An Optimal Way
Structuring An ABAP Report In An Optimal WayBlackvard
 
Critical software developement
Critical software developementCritical software developement
Critical software developementnedseb
 

Similaire à Kaust rhino workshop 2011 (20)

Android's security architecture
Android's security architectureAndroid's security architecture
Android's security architecture
 
Running your Spring Apps in the Cloud Javaone 2014
Running your Spring Apps in the Cloud Javaone 2014Running your Spring Apps in the Cloud Javaone 2014
Running your Spring Apps in the Cloud Javaone 2014
 
Multimedia document processing using the Weblab platform: AXES project use ca...
Multimedia document processing using the Weblab platform: AXES project use ca...Multimedia document processing using the Weblab platform: AXES project use ca...
Multimedia document processing using the Weblab platform: AXES project use ca...
 
Bridging the gap between business and technology - Behaviour Driven Developme...
Bridging the gap between business and technology - Behaviour Driven Developme...Bridging the gap between business and technology - Behaviour Driven Developme...
Bridging the gap between business and technology - Behaviour Driven Developme...
 
Where is cold fusion headed
Where is cold fusion headedWhere is cold fusion headed
Where is cold fusion headed
 
Best practices iOS meetup - pmd
Best practices iOS meetup - pmdBest practices iOS meetup - pmd
Best practices iOS meetup - pmd
 
Extending js codemotion warsaw 2016
Extending js codemotion warsaw 2016Extending js codemotion warsaw 2016
Extending js codemotion warsaw 2016
 
DDD on example of Symfony (SfCampUA14)
DDD on example of Symfony (SfCampUA14)DDD on example of Symfony (SfCampUA14)
DDD on example of Symfony (SfCampUA14)
 
Creating an all-purpose REST API for Cloud services using OSGi and Sling - C ...
Creating an all-purpose REST API for Cloud services using OSGi and Sling - C ...Creating an all-purpose REST API for Cloud services using OSGi and Sling - C ...
Creating an all-purpose REST API for Cloud services using OSGi and Sling - C ...
 
ColdFusion 11 Overview - CFSummit 2013
ColdFusion 11 Overview - CFSummit 2013ColdFusion 11 Overview - CFSummit 2013
ColdFusion 11 Overview - CFSummit 2013
 
How to build Sdk? Best practices
How to build Sdk? Best practicesHow to build Sdk? Best practices
How to build Sdk? Best practices
 
Debugging Drupal - How to Debug your Drupal Application
Debugging Drupal - How to Debug your Drupal ApplicationDebugging Drupal - How to Debug your Drupal Application
Debugging Drupal - How to Debug your Drupal Application
 
Bdd Net Frameworks
Bdd Net FrameworksBdd Net Frameworks
Bdd Net Frameworks
 
Drools Workshop 2015 - LATAM
Drools Workshop 2015 - LATAMDrools Workshop 2015 - LATAM
Drools Workshop 2015 - LATAM
 
LDOW2015 - Uduvudu: a Graph-Aware and Adaptive UI Engine for Linked Data
LDOW2015 - Uduvudu: a Graph-Aware and Adaptive UI Engine for Linked DataLDOW2015 - Uduvudu: a Graph-Aware and Adaptive UI Engine for Linked Data
LDOW2015 - Uduvudu: a Graph-Aware and Adaptive UI Engine for Linked Data
 
Zend_Tool: Rapid Application Development with Zend Framework
Zend_Tool: Rapid Application Development with Zend FrameworkZend_Tool: Rapid Application Development with Zend Framework
Zend_Tool: Rapid Application Development with Zend Framework
 
Better Code: Concurrency
Better Code: ConcurrencyBetter Code: Concurrency
Better Code: Concurrency
 
PHP QA Tools
PHP QA ToolsPHP QA Tools
PHP QA Tools
 
Structuring An ABAP Report In An Optimal Way
Structuring An ABAP Report In An Optimal WayStructuring An ABAP Report In An Optimal Way
Structuring An ABAP Report In An Optimal Way
 
Critical software developement
Critical software developementCritical software developement
Critical software developement
 

Plus de khaled Mohamed Ahmed Abd El Gawad

Plus de khaled Mohamed Ahmed Abd El Gawad (6)

Virtual city presentation
Virtual city presentationVirtual city presentation
Virtual city presentation
 
Interactive Walkthrough in Virtual Cities and its Applications in Urban Design
Interactive Walkthrough in Virtual Cities and its Applications in Urban DesignInteractive Walkthrough in Virtual Cities and its Applications in Urban Design
Interactive Walkthrough in Virtual Cities and its Applications in Urban Design
 
Managing People Towards Superior Performance - Session 3
Managing People Towards Superior Performance - Session 3Managing People Towards Superior Performance - Session 3
Managing People Towards Superior Performance - Session 3
 
Be happy -10 Things to Stop Doing Right Now
Be happy -10 Things to Stop Doing Right NowBe happy -10 Things to Stop Doing Right Now
Be happy -10 Things to Stop Doing Right Now
 
How to be successful
How to be successfulHow to be successful
How to be successful
 
Managing People Towards Superior Performance - Leadership Training
Managing People Towards Superior Performance - Leadership TrainingManaging People Towards Superior Performance - Leadership Training
Managing People Towards Superior Performance - Leadership Training
 

Dernier

4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptx4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptxmary850239
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxVanesaIglesias10
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfPatidar M
 
Reading and Writing Skills 11 quarter 4 melc 1
Reading and Writing Skills 11 quarter 4 melc 1Reading and Writing Skills 11 quarter 4 melc 1
Reading and Writing Skills 11 quarter 4 melc 1GloryAnnCastre1
 
ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfVanessa Camilleri
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationdeepaannamalai16
 
Measures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataMeasures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataBabyAnnMotar
 
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...DhatriParmar
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptxmary850239
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxlancelewisportillo
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptxmary850239
 
Mythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWMythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWQuiz Club NITW
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Projectjordimapav
 
week 1 cookery 8 fourth - quarter .pptx
week 1 cookery 8  fourth  -  quarter .pptxweek 1 cookery 8  fourth  -  quarter .pptx
week 1 cookery 8 fourth - quarter .pptxJonalynLegaspi2
 
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptxDIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptxMichelleTuguinay1
 

Dernier (20)

4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptx4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptx
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptx
 
Faculty Profile prashantha K EEE dept Sri Sairam college of Engineering
Faculty Profile prashantha K EEE dept Sri Sairam college of EngineeringFaculty Profile prashantha K EEE dept Sri Sairam college of Engineering
Faculty Profile prashantha K EEE dept Sri Sairam college of Engineering
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdf
 
Reading and Writing Skills 11 quarter 4 melc 1
Reading and Writing Skills 11 quarter 4 melc 1Reading and Writing Skills 11 quarter 4 melc 1
Reading and Writing Skills 11 quarter 4 melc 1
 
Mattingly "AI & Prompt Design: Large Language Models"
Mattingly "AI & Prompt Design: Large Language Models"Mattingly "AI & Prompt Design: Large Language Models"
Mattingly "AI & Prompt Design: Large Language Models"
 
ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdf
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentation
 
Measures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataMeasures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped data
 
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx
 
Mythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWMythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITW
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Project
 
week 1 cookery 8 fourth - quarter .pptx
week 1 cookery 8  fourth  -  quarter .pptxweek 1 cookery 8  fourth  -  quarter .pptx
week 1 cookery 8 fourth - quarter .pptx
 
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptxDIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
 

Kaust rhino workshop 2011