Saturday, September 1, 2007

Website Reference List

RhinoScript Wiki Site:
http://en.wiki.mcneel.com/default.aspx/McNeel/RhinoScript.html

RhinoScript Hand Out (old):
http://www.reconstructivism.net/index.htm?handout.htm

Scripting and Computational Geometery:
http://www.dritsas.net/scripting/scripting_book.html

Rhinoscript 101 Hand Out (new):
http://en.wiki.mcneel.com/default.aspx/McNeel/RhinoScript101

VB Keywords:
http://www.devlist.com/VbDotNet.aspx
http://msdn2.microsoft.com/en-us/library/ksh7h19t(VS.80).aspx

VB Script Fundamentals:
http://msdn2.microsoft.com/en-us/library/0ad0dkea.aspx

Conditional Statements:
http://msdn2.microsoft.com/en-us/library/9t9x467f.aspx

Loops:
http://msdn2.microsoft.com/en-us/library/cbe735w2.aspx

'L-System

Option Explicit
'OPTION EXPLICIT forces you to declare variables with the DIM or REDIM statement
'OPTION EXPLICIT should always be the first line in the code
'Script written by Charles Portelli'Script version Wednesday, August 29, 2007 3:05:53 PM

'Using the apostrophe allows for comments to be added in to the code
'Comments are usefull because they allow us to add notes to the code
'that do not affect the execution of the code

'GLOBAL Variables = variables that are used through out the code
'Always declare you global variables in the begining
'--------------------------------------------
Dim axiom : axiom = "abc" 'declaring the axiom
Dim numberOfGenerations : numberofgenerations = 6 'declaring the number of generations

ReDim rules(2,1) 'declaring the rules
rules(0,0) = "a" 'A -> B the letter A gets replaced with the letter B
rules(0,1) = "b"
rules(1,0) = "b" 'B -> A the letter B gets replaced with the letter A
rules(1,1) = "a"
rules(2,0) = "c" 'C -> AA the letter C gets replaced with the letters AA
rules(2,1) = "aa"
'--------------------------------------------

Call Main() 'this tells the computer to go to the MAIN SUB hence Call Main

Sub Main()
Dim i,j 'this is where you declare you local variables
Dim arrPoint, x,y,z
x=0 : y=0 : z=0
'perform the string replacement for each generation
For j=0 To numberOfGenerations
rhino.print axiom 'print the axiom in the command line

'draw each generation
For i=1 To len(axiom) 'for every letter in the axiom
arrPoint = array(j,i-1,z)
rhino.addTextDot Mid(axiom, i, 1), arrPoint 'add a text dot with each letter from the axiom
Next

For i=0 To Ubound(rules,1) 'for each of the rules in the first dimension
'a match is converted into a number
axiom = Replace(axiom, rules(i,0), i) 'take the letter in the axiom and replace it with a number
Next

For i=0 To Ubound(rules,1)
'the number is replaced with the result of the substitution rule
axiom = Replace(axiom, i, rules(i,1)) 'now replace that number based on your rules
Next

Next
Rhino.Print("finished!") 'when finished display FINISHED in the command line
End Sub 'this marks the end of the MAIN SUB