SlideShare une entreprise Scribd logo
1  sur  33
RhinoScript 101 Creativity "orhowto do interestingthingsthat are noteasyto do withthe mouse" Dr. Ricardo Sosa (rdsosam@itesm.mx)
Nevermind the code… ' 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 Execute when “DrawCurve” Is called above 	Call Rhino.enableRedraw(False) ' nevermind this, it speeds up the execution of the code 	Dim controlpoints(1)  ' controlpoints is an array of 3-D points (see next slide) controlpoints(0) = Array(0,0,0) ' x = 0, y = 0, z = 0 controlpoints(1) = Array(10,5,15) ' x = 10, y = 5, z = 15 Rhino.Print ( "Curve ID: " + Rhino.AddCurve(controlpoints) ) ' this draws the curve and prints its I.D. Rhino.Print ( "Sphere ID: " + Rhino.AddSphere (controlpoints(1), 1) ) ' this draws a sphere and prints its I.D. 	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 Dr. Ricardo Sosa (rdsosam@itesm.mx)
sphere  of radius 1 x=10, y=5, z=15 x=0, y=0, z=0 Dr. Ricardo Sosa (rdsosam@itesm.mx)
AddSphere(controlpoints(1), 1) AddCurve(controlpoints) Dr. Ricardo Sosa (rdsosam@itesm.mx)
Holdon! What'san "array"? Dr. Ricardo Sosa (rdsosam@itesm.mx)
Anarrayislike a box Dr. Ricardo Sosa (rdsosam@itesm.mx)
A box thatholds 3D coordinates Dr. Ricardo Sosa (rdsosam@itesm.mx)
' 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(1)  ' controlpoints is an array of 3-D points (see next slide) 	controlpoints(0) = Array(0,0,0) ' x = 0, y = 0, z = 0 	controlpoints(1) = Array(10,5,15) ' x = 10, y = 5, z = 15 	Rhino.Print ( "Curve ID: " + Rhino.AddCurve(controlpoints) ) ' this draws the curve and prints its I.D. 	Rhino.Print ( "Sphere ID: " + Rhino.AddSphere (controlpoints(1), 1) ) ' this draws a sphere and its I.D. 	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 Dr. Ricardo Sosa (rdsosam@itesm.mx)
Curve ID: 2312ea39-2894-4d1f-b31e-406fa88e5824 Sphere ID: 19ea41fa-0e4f-4514-b701-36c39939113a Dr. Ricardo Sosa (rdsosam@itesm.mx)
Now some randomness… ' 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(1)  ' controlpoints is an array of 3-D points (see next slide) controlpoints(0) = Array(0,0,0) ' x = 0, y = 0, z = 0 controlpoints(1) = Array(randomBetween(-10,10),randomBetween(-10,10),15) ' x = random, y = random, z = 15 Rhino.Print ( "Curve ID: " + Rhino.AddCurve(controlpoints) ) ' this draws the curve and prints its I.D. Rhino.Print ( "Sphere ID: " + Rhino.AddSphere (controlpoints(1), 1) ) ' this draws a sphere and its I.D. 	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 Dr. Ricardo Sosa (rdsosam@itesm.mx)
After running the code a few times you get something like this… Dr. Ricardo Sosa (rdsosam@itesm.mx)
Now some recursion… ' 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(1)  ' controlpoints is an array of 3-D points (see next slide) Dim i 	For i=0 To 100 controlpoints(0) = Array(0,0,0) ' x = 0, y = 0, z = 0 controlpoints(1) = Array(randomBetween(-10,10),randomBetween(-10,10),15) ' x = random, y = random, z = 15 Rhino.AddCurvecontrolpoints ' this draws the curve Rhino.AddSpherecontrolpoints(1), 1  ' this draws a sphere 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 Dr. Ricardo Sosa (rdsosam@itesm.mx)
Dr. Ricardo Sosa (rdsosam@itesm.mx)
Dr. Ricardo Sosa (rdsosam@itesm.mx)
Dr. Ricardo Sosa (rdsosam@itesm.mx) One thousand times… (slooow!)
More interesting curves… ' 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(2), 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)  Rhino.AddCurvecontrolpoints, 2 ' this draws the curve of two degrees now Rhino.AddSpherecontrolpoints(1), 0.25  ' this draws a small sphere at second 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 Dr. Ricardo Sosa (rdsosam@itesm.mx)
Dr. Ricardo Sosa (rdsosam@itesm.mx)
Dr. Ricardo Sosa (rdsosam@itesm.mx) Selectany line and press F10:Youwillnoticethatthesmallspheres are drawn at thesecond control point…
' 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(2), 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)  Rhino.AddCurvecontrolpoints, 2 ' this draws the curve Rhino.AddSpherecontrolpoints(1), 0.25  ' this draws a small sphere at second point Rhino.AddSpherecontrolpoints(2), 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 Dr. Ricardo Sosa (rdsosam@itesm.mx)
Dr. Ricardo Sosa (rdsosam@itesm.mx)
Time for a challenge… How do youachievethefollowing? Dr. Ricardo Sosa (rdsosam@itesm.mx)
Dr. Ricardo Sosa (rdsosam@itesm.mx)
' 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.AddCurvecontrolpoints, 3 ' this draws the curve Rhino.AddSpherecontrolpoints(1), 0.25  ' this draws a small sphere at second point Rhino.AddSpherecontrolpoints(2), 0.25  ' this draws a big sphere at third point Rhino.AddSpherecontrolpoints(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 Dr. Ricardo Sosa (rdsosam@itesm.mx)
Dr. Ricardo Sosa (rdsosam@itesm.mx)
Addanother set of coordinates… Dr. Ricardo Sosa (rdsosam@itesm.mx)
Rhino.Command "anycommand" Shift + Rightclickanytoolicontoseeits _Command Dr. Ricardo Sosa (rdsosam@itesm.mx)
Dr. Ricardo Sosa (rdsosam@itesm.mx)
' 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)  	Dim strCmd, curveID 	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)  curveID = Rhino.AddCurve(controlpoints, 3) ' this draws the curve  Rhino.SelectObject(curveID) Rhino.Command "_Pipe " & 1.0 & " Enter "  & 1.0 & " Enter" 	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 Dr. Ricardo Sosa (rdsosam@itesm.mx)
Dr. Ricardo Sosa (rdsosam@itesm.mx)
Dr. Ricardo Sosa (rdsosam@itesm.mx)
Dr. Ricardo Sosa (rdsosam@itesm.mx)
After you add a curve, select it with: Rhino.SelectObject(curveID) Then apply the command: Rhino.Command"_Pipe " & 1.0 & " Enter "  & 1.0 & " Enter" Dr. Ricardo Sosa (rdsosam@itesm.mx)
Due next class… Do somethinginteresting of yourown! Dr. Ricardo Sosa (rdsosam@itesm.mx)

Contenu connexe

Tendances

Toonz code leaves much to be desired
Toonz code leaves much to be desiredToonz code leaves much to be desired
Toonz code leaves much to be desiredPVS-Studio
 
I want to sell a PVS-Studio license to the Intel company
I want to sell a PVS-Studio license to the Intel companyI want to sell a PVS-Studio license to the Intel company
I want to sell a PVS-Studio license to the Intel companyPVS-Studio
 
Computer programming subject notes. Quick easy notes for C Programming.Cheat ...
Computer programming subject notes. Quick easy notes for C Programming.Cheat ...Computer programming subject notes. Quick easy notes for C Programming.Cheat ...
Computer programming subject notes. Quick easy notes for C Programming.Cheat ...DR B.Surendiran .
 
Asterisk: PVS-Studio Takes Up Telephony
Asterisk: PVS-Studio Takes Up TelephonyAsterisk: PVS-Studio Takes Up Telephony
Asterisk: PVS-Studio Takes Up TelephonyAndrey Karpov
 
Csci101 lect04 advanced_selection
Csci101 lect04 advanced_selectionCsci101 lect04 advanced_selection
Csci101 lect04 advanced_selectionElsayed Hemayed
 
Chapter 5 Balagurusamy Programming ANSI in c
Chapter 5 Balagurusamy Programming ANSI  in cChapter 5 Balagurusamy Programming ANSI  in c
Chapter 5 Balagurusamy Programming ANSI in cBUBT
 

Tendances (7)

Es6 overview
Es6 overviewEs6 overview
Es6 overview
 
Toonz code leaves much to be desired
Toonz code leaves much to be desiredToonz code leaves much to be desired
Toonz code leaves much to be desired
 
I want to sell a PVS-Studio license to the Intel company
I want to sell a PVS-Studio license to the Intel companyI want to sell a PVS-Studio license to the Intel company
I want to sell a PVS-Studio license to the Intel company
 
Computer programming subject notes. Quick easy notes for C Programming.Cheat ...
Computer programming subject notes. Quick easy notes for C Programming.Cheat ...Computer programming subject notes. Quick easy notes for C Programming.Cheat ...
Computer programming subject notes. Quick easy notes for C Programming.Cheat ...
 
Asterisk: PVS-Studio Takes Up Telephony
Asterisk: PVS-Studio Takes Up TelephonyAsterisk: PVS-Studio Takes Up Telephony
Asterisk: PVS-Studio Takes Up Telephony
 
Csci101 lect04 advanced_selection
Csci101 lect04 advanced_selectionCsci101 lect04 advanced_selection
Csci101 lect04 advanced_selection
 
Chapter 5 Balagurusamy Programming ANSI in c
Chapter 5 Balagurusamy Programming ANSI  in cChapter 5 Balagurusamy Programming ANSI  in c
Chapter 5 Balagurusamy Programming ANSI in c
 

Similaire à Rhino script 101 creativity

Write a program to check a given number is prime or not
Write a program to check a given number is prime or notWrite a program to check a given number is prime or not
Write a program to check a given number is prime or notaluavi
 
Programming python quick intro for schools
Programming python quick intro for schoolsProgramming python quick intro for schools
Programming python quick intro for schoolsDan Bowen
 
Python programming workshop session 2
Python programming workshop session 2Python programming workshop session 2
Python programming workshop session 2Abdul Haseeb
 
error 2.pdf101316, 6(46 PM01_errorPage 1 of 5http.docx
error 2.pdf101316, 6(46 PM01_errorPage 1 of 5http.docxerror 2.pdf101316, 6(46 PM01_errorPage 1 of 5http.docx
error 2.pdf101316, 6(46 PM01_errorPage 1 of 5http.docxSALU18
 
Google I/O 2013 - Android Graphics Performance
Google I/O 2013 - Android Graphics PerformanceGoogle I/O 2013 - Android Graphics Performance
Google I/O 2013 - Android Graphics PerformanceDouO
 
Google I/O 2013 - Android Graphics Performance
Google I/O 2013 - Android Graphics PerformanceGoogle I/O 2013 - Android Graphics Performance
Google I/O 2013 - Android Graphics PerformanceDouO
 
C decision making and looping.
C decision making and looping.C decision making and looping.
C decision making and looping.Haard Shah
 
Checking the code of Valgrind dynamic analyzer by a static analyzer
Checking the code of Valgrind dynamic analyzer by a static analyzerChecking the code of Valgrind dynamic analyzer by a static analyzer
Checking the code of Valgrind dynamic analyzer by a static analyzerPVS-Studio
 
Standford 2015 week3: Objective-C Compatibility, Property List, Views
Standford 2015 week3: Objective-C Compatibility, Property List, ViewsStandford 2015 week3: Objective-C Compatibility, Property List, Views
Standford 2015 week3: Objective-C Compatibility, Property List, Views彼得潘 Pan
 
Automated Design Validation The Solid Works Api
Automated Design Validation The Solid Works ApiAutomated Design Validation The Solid Works Api
Automated Design Validation The Solid Works ApiRazorleaf Corporation
 
Introduction to Basic C programming 02
Introduction to Basic C programming 02Introduction to Basic C programming 02
Introduction to Basic C programming 02Wingston
 
Notes on assignment in r
Notes on assignment in rNotes on assignment in r
Notes on assignment in rTJ Mahr
 
Arduino - Module 1.pdf
Arduino - Module 1.pdfArduino - Module 1.pdf
Arduino - Module 1.pdfrazonclarence4
 
Intro to Arduino Programming.pdf
Intro to Arduino Programming.pdfIntro to Arduino Programming.pdf
Intro to Arduino Programming.pdfHimanshuDon1
 
Control structure of c
Control structure of cControl structure of c
Control structure of cKomal Kotak
 
Beginning direct3d gameprogramming05_thebasics_20160421_jintaeks
Beginning direct3d gameprogramming05_thebasics_20160421_jintaeksBeginning direct3d gameprogramming05_thebasics_20160421_jintaeks
Beginning direct3d gameprogramming05_thebasics_20160421_jintaeksJinTaek Seo
 
Here is the grading matrix where the TA will leave feedback. If you .docx
Here is the grading matrix where the TA will leave feedback. If you .docxHere is the grading matrix where the TA will leave feedback. If you .docx
Here is the grading matrix where the TA will leave feedback. If you .docxtrappiteboni
 
Cs291 assignment solution
Cs291 assignment solutionCs291 assignment solution
Cs291 assignment solutionKuntal Bhowmick
 

Similaire à Rhino script 101 creativity (20)

Write a program to check a given number is prime or not
Write a program to check a given number is prime or notWrite a program to check a given number is prime or not
Write a program to check a given number is prime or not
 
Programming python quick intro for schools
Programming python quick intro for schoolsProgramming python quick intro for schools
Programming python quick intro for schools
 
Python programming workshop session 2
Python programming workshop session 2Python programming workshop session 2
Python programming workshop session 2
 
error 2.pdf101316, 6(46 PM01_errorPage 1 of 5http.docx
error 2.pdf101316, 6(46 PM01_errorPage 1 of 5http.docxerror 2.pdf101316, 6(46 PM01_errorPage 1 of 5http.docx
error 2.pdf101316, 6(46 PM01_errorPage 1 of 5http.docx
 
Google I/O 2013 - Android Graphics Performance
Google I/O 2013 - Android Graphics PerformanceGoogle I/O 2013 - Android Graphics Performance
Google I/O 2013 - Android Graphics Performance
 
Google I/O 2013 - Android Graphics Performance
Google I/O 2013 - Android Graphics PerformanceGoogle I/O 2013 - Android Graphics Performance
Google I/O 2013 - Android Graphics Performance
 
C decision making and looping.
C decision making and looping.C decision making and looping.
C decision making and looping.
 
Checking the code of Valgrind dynamic analyzer by a static analyzer
Checking the code of Valgrind dynamic analyzer by a static analyzerChecking the code of Valgrind dynamic analyzer by a static analyzer
Checking the code of Valgrind dynamic analyzer by a static analyzer
 
Standford 2015 week3: Objective-C Compatibility, Property List, Views
Standford 2015 week3: Objective-C Compatibility, Property List, ViewsStandford 2015 week3: Objective-C Compatibility, Property List, Views
Standford 2015 week3: Objective-C Compatibility, Property List, Views
 
Automated Design Validation The Solid Works Api
Automated Design Validation The Solid Works ApiAutomated Design Validation The Solid Works Api
Automated Design Validation The Solid Works Api
 
Introduction to Basic C programming 02
Introduction to Basic C programming 02Introduction to Basic C programming 02
Introduction to Basic C programming 02
 
Notes on assignment in r
Notes on assignment in rNotes on assignment in r
Notes on assignment in r
 
Arduino - Module 1.pdf
Arduino - Module 1.pdfArduino - Module 1.pdf
Arduino - Module 1.pdf
 
Intro to Arduino Programming.pdf
Intro to Arduino Programming.pdfIntro to Arduino Programming.pdf
Intro to Arduino Programming.pdf
 
Control structure of c
Control structure of cControl structure of c
Control structure of c
 
Week 4
Week 4Week 4
Week 4
 
Beginning direct3d gameprogramming05_thebasics_20160421_jintaeks
Beginning direct3d gameprogramming05_thebasics_20160421_jintaeksBeginning direct3d gameprogramming05_thebasics_20160421_jintaeks
Beginning direct3d gameprogramming05_thebasics_20160421_jintaeks
 
JavaScript 101
JavaScript 101JavaScript 101
JavaScript 101
 
Here is the grading matrix where the TA will leave feedback. If you .docx
Here is the grading matrix where the TA will leave feedback. If you .docxHere is the grading matrix where the TA will leave feedback. If you .docx
Here is the grading matrix where the TA will leave feedback. If you .docx
 
Cs291 assignment solution
Cs291 assignment solutionCs291 assignment solution
Cs291 assignment solution
 

Plus de R. Sosa

Week 1: Lecture What is Design by Ricardo Sosa
Week 1: Lecture What is Design by Ricardo SosaWeek 1: Lecture What is Design by Ricardo Sosa
Week 1: Lecture What is Design by Ricardo SosaR. Sosa
 
100 IDEAS THAT CHANGED DESIGN
100 IDEAS THAT CHANGED DESIGN100 IDEAS THAT CHANGED DESIGN
100 IDEAS THAT CHANGED DESIGNR. Sosa
 
Edgar Morin El Metodo 4: Las ideas
Edgar Morin El Metodo 4: Las ideasEdgar Morin El Metodo 4: Las ideas
Edgar Morin El Metodo 4: Las ideasR. Sosa
 
USYD Virtual Design lecture
USYD Virtual Design lectureUSYD Virtual Design lecture
USYD Virtual Design lectureR. Sosa
 
Design School Confidential Class Projects
Design School Confidential Class ProjectsDesign School Confidential Class Projects
Design School Confidential Class ProjectsR. Sosa
 
La Golosina Visual de Ignacio Ramonet
La Golosina Visual de Ignacio RamonetLa Golosina Visual de Ignacio Ramonet
La Golosina Visual de Ignacio RamonetR. Sosa
 
Apocalípticos e Integrados
Apocalípticos e IntegradosApocalípticos e Integrados
Apocalípticos e IntegradosR. Sosa
 
Understanding Computers and Cognition
Understanding Computers and CognitionUnderstanding Computers and Cognition
Understanding Computers and CognitionR. Sosa
 
Convivial Toolbox
Convivial ToolboxConvivial Toolbox
Convivial ToolboxR. Sosa
 
Brecht on Theatre.pdf
Brecht on Theatre.pdfBrecht on Theatre.pdf
Brecht on Theatre.pdfR. Sosa
 
Simulation (or Computation) and its Discontents
Simulation (or Computation) and its DiscontentsSimulation (or Computation) and its Discontents
Simulation (or Computation) and its DiscontentsR. Sosa
 
Gui Bonsiepe: Las Siete Columnas del Diseño_.pdf
Gui Bonsiepe: Las Siete Columnas del Diseño_.pdfGui Bonsiepe: Las Siete Columnas del Diseño_.pdf
Gui Bonsiepe: Las Siete Columnas del Diseño_.pdfR. Sosa
 
The Invention of Creativity by Reckwitz.pdf
The Invention of Creativity by Reckwitz.pdfThe Invention of Creativity by Reckwitz.pdf
The Invention of Creativity by Reckwitz.pdfR. Sosa
 
Write your Thesis using AI
Write your Thesis using AIWrite your Thesis using AI
Write your Thesis using AIR. Sosa
 
Tikanga Māori
Tikanga MāoriTikanga Māori
Tikanga MāoriR. Sosa
 
The richness of life, Stephen Jay Gould
The richness of life, Stephen Jay GouldThe richness of life, Stephen Jay Gould
The richness of life, Stephen Jay GouldR. Sosa
 
Las Ideas Estéticas de Marx.pdf
Las Ideas Estéticas de Marx.pdfLas Ideas Estéticas de Marx.pdf
Las Ideas Estéticas de Marx.pdfR. Sosa
 
Māori Philosophies
Māori PhilosophiesMāori Philosophies
Māori PhilosophiesR. Sosa
 
Herbot Design Analysis annotated 58 points.pdf
Herbot Design Analysis annotated 58 points.pdfHerbot Design Analysis annotated 58 points.pdf
Herbot Design Analysis annotated 58 points.pdfR. Sosa
 

Plus de R. Sosa (20)

Week 1: Lecture What is Design by Ricardo Sosa
Week 1: Lecture What is Design by Ricardo SosaWeek 1: Lecture What is Design by Ricardo Sosa
Week 1: Lecture What is Design by Ricardo Sosa
 
Causation
CausationCausation
Causation
 
100 IDEAS THAT CHANGED DESIGN
100 IDEAS THAT CHANGED DESIGN100 IDEAS THAT CHANGED DESIGN
100 IDEAS THAT CHANGED DESIGN
 
Edgar Morin El Metodo 4: Las ideas
Edgar Morin El Metodo 4: Las ideasEdgar Morin El Metodo 4: Las ideas
Edgar Morin El Metodo 4: Las ideas
 
USYD Virtual Design lecture
USYD Virtual Design lectureUSYD Virtual Design lecture
USYD Virtual Design lecture
 
Design School Confidential Class Projects
Design School Confidential Class ProjectsDesign School Confidential Class Projects
Design School Confidential Class Projects
 
La Golosina Visual de Ignacio Ramonet
La Golosina Visual de Ignacio RamonetLa Golosina Visual de Ignacio Ramonet
La Golosina Visual de Ignacio Ramonet
 
Apocalípticos e Integrados
Apocalípticos e IntegradosApocalípticos e Integrados
Apocalípticos e Integrados
 
Understanding Computers and Cognition
Understanding Computers and CognitionUnderstanding Computers and Cognition
Understanding Computers and Cognition
 
Convivial Toolbox
Convivial ToolboxConvivial Toolbox
Convivial Toolbox
 
Brecht on Theatre.pdf
Brecht on Theatre.pdfBrecht on Theatre.pdf
Brecht on Theatre.pdf
 
Simulation (or Computation) and its Discontents
Simulation (or Computation) and its DiscontentsSimulation (or Computation) and its Discontents
Simulation (or Computation) and its Discontents
 
Gui Bonsiepe: Las Siete Columnas del Diseño_.pdf
Gui Bonsiepe: Las Siete Columnas del Diseño_.pdfGui Bonsiepe: Las Siete Columnas del Diseño_.pdf
Gui Bonsiepe: Las Siete Columnas del Diseño_.pdf
 
The Invention of Creativity by Reckwitz.pdf
The Invention of Creativity by Reckwitz.pdfThe Invention of Creativity by Reckwitz.pdf
The Invention of Creativity by Reckwitz.pdf
 
Write your Thesis using AI
Write your Thesis using AIWrite your Thesis using AI
Write your Thesis using AI
 
Tikanga Māori
Tikanga MāoriTikanga Māori
Tikanga Māori
 
The richness of life, Stephen Jay Gould
The richness of life, Stephen Jay GouldThe richness of life, Stephen Jay Gould
The richness of life, Stephen Jay Gould
 
Las Ideas Estéticas de Marx.pdf
Las Ideas Estéticas de Marx.pdfLas Ideas Estéticas de Marx.pdf
Las Ideas Estéticas de Marx.pdf
 
Māori Philosophies
Māori PhilosophiesMāori Philosophies
Māori Philosophies
 
Herbot Design Analysis annotated 58 points.pdf
Herbot Design Analysis annotated 58 points.pdfHerbot Design Analysis annotated 58 points.pdf
Herbot Design Analysis annotated 58 points.pdf
 

Rhino script 101 creativity

  • 1. RhinoScript 101 Creativity "orhowto do interestingthingsthat are noteasyto do withthe mouse" Dr. Ricardo Sosa (rdsosam@itesm.mx)
  • 2. Nevermind the code… ' 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 Execute when “DrawCurve” Is called above Call Rhino.enableRedraw(False) ' nevermind this, it speeds up the execution of the code Dim controlpoints(1) ' controlpoints is an array of 3-D points (see next slide) controlpoints(0) = Array(0,0,0) ' x = 0, y = 0, z = 0 controlpoints(1) = Array(10,5,15) ' x = 10, y = 5, z = 15 Rhino.Print ( "Curve ID: " + Rhino.AddCurve(controlpoints) ) ' this draws the curve and prints its I.D. Rhino.Print ( "Sphere ID: " + Rhino.AddSphere (controlpoints(1), 1) ) ' this draws a sphere and prints its I.D. 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 Dr. Ricardo Sosa (rdsosam@itesm.mx)
  • 3. sphere of radius 1 x=10, y=5, z=15 x=0, y=0, z=0 Dr. Ricardo Sosa (rdsosam@itesm.mx)
  • 4. AddSphere(controlpoints(1), 1) AddCurve(controlpoints) Dr. Ricardo Sosa (rdsosam@itesm.mx)
  • 5. Holdon! What'san "array"? Dr. Ricardo Sosa (rdsosam@itesm.mx)
  • 6. Anarrayislike a box Dr. Ricardo Sosa (rdsosam@itesm.mx)
  • 7. A box thatholds 3D coordinates Dr. Ricardo Sosa (rdsosam@itesm.mx)
  • 8. ' 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(1) ' controlpoints is an array of 3-D points (see next slide) controlpoints(0) = Array(0,0,0) ' x = 0, y = 0, z = 0 controlpoints(1) = Array(10,5,15) ' x = 10, y = 5, z = 15 Rhino.Print ( "Curve ID: " + Rhino.AddCurve(controlpoints) ) ' this draws the curve and prints its I.D. Rhino.Print ( "Sphere ID: " + Rhino.AddSphere (controlpoints(1), 1) ) ' this draws a sphere and its I.D. 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 Dr. Ricardo Sosa (rdsosam@itesm.mx)
  • 9. Curve ID: 2312ea39-2894-4d1f-b31e-406fa88e5824 Sphere ID: 19ea41fa-0e4f-4514-b701-36c39939113a Dr. Ricardo Sosa (rdsosam@itesm.mx)
  • 10. Now some randomness… ' 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(1) ' controlpoints is an array of 3-D points (see next slide) controlpoints(0) = Array(0,0,0) ' x = 0, y = 0, z = 0 controlpoints(1) = Array(randomBetween(-10,10),randomBetween(-10,10),15) ' x = random, y = random, z = 15 Rhino.Print ( "Curve ID: " + Rhino.AddCurve(controlpoints) ) ' this draws the curve and prints its I.D. Rhino.Print ( "Sphere ID: " + Rhino.AddSphere (controlpoints(1), 1) ) ' this draws a sphere and its I.D. 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 Dr. Ricardo Sosa (rdsosam@itesm.mx)
  • 11. After running the code a few times you get something like this… Dr. Ricardo Sosa (rdsosam@itesm.mx)
  • 12. Now some recursion… ' 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(1) ' controlpoints is an array of 3-D points (see next slide) Dim i For i=0 To 100 controlpoints(0) = Array(0,0,0) ' x = 0, y = 0, z = 0 controlpoints(1) = Array(randomBetween(-10,10),randomBetween(-10,10),15) ' x = random, y = random, z = 15 Rhino.AddCurvecontrolpoints ' this draws the curve Rhino.AddSpherecontrolpoints(1), 1 ' this draws a sphere 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 Dr. Ricardo Sosa (rdsosam@itesm.mx)
  • 13. Dr. Ricardo Sosa (rdsosam@itesm.mx)
  • 14. Dr. Ricardo Sosa (rdsosam@itesm.mx)
  • 15. Dr. Ricardo Sosa (rdsosam@itesm.mx) One thousand times… (slooow!)
  • 16. More interesting curves… ' 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(2), 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) Rhino.AddCurvecontrolpoints, 2 ' this draws the curve of two degrees now Rhino.AddSpherecontrolpoints(1), 0.25 ' this draws a small sphere at second 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 Dr. Ricardo Sosa (rdsosam@itesm.mx)
  • 17. Dr. Ricardo Sosa (rdsosam@itesm.mx)
  • 18. Dr. Ricardo Sosa (rdsosam@itesm.mx) Selectany line and press F10:Youwillnoticethatthesmallspheres are drawn at thesecond control point…
  • 19. ' 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(2), 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) Rhino.AddCurvecontrolpoints, 2 ' this draws the curve Rhino.AddSpherecontrolpoints(1), 0.25 ' this draws a small sphere at second point Rhino.AddSpherecontrolpoints(2), 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 Dr. Ricardo Sosa (rdsosam@itesm.mx)
  • 20. Dr. Ricardo Sosa (rdsosam@itesm.mx)
  • 21. Time for a challenge… How do youachievethefollowing? Dr. Ricardo Sosa (rdsosam@itesm.mx)
  • 22. Dr. Ricardo Sosa (rdsosam@itesm.mx)
  • 23. ' 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.AddCurvecontrolpoints, 3 ' this draws the curve Rhino.AddSpherecontrolpoints(1), 0.25 ' this draws a small sphere at second point Rhino.AddSpherecontrolpoints(2), 0.25 ' this draws a big sphere at third point Rhino.AddSpherecontrolpoints(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 Dr. Ricardo Sosa (rdsosam@itesm.mx)
  • 24. Dr. Ricardo Sosa (rdsosam@itesm.mx)
  • 25. Addanother set of coordinates… Dr. Ricardo Sosa (rdsosam@itesm.mx)
  • 26. Rhino.Command "anycommand" Shift + Rightclickanytoolicontoseeits _Command Dr. Ricardo Sosa (rdsosam@itesm.mx)
  • 27. Dr. Ricardo Sosa (rdsosam@itesm.mx)
  • 28. ' 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) Dim strCmd, curveID 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) curveID = Rhino.AddCurve(controlpoints, 3) ' this draws the curve Rhino.SelectObject(curveID) Rhino.Command "_Pipe " & 1.0 & " Enter " & 1.0 & " Enter" 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 Dr. Ricardo Sosa (rdsosam@itesm.mx)
  • 29. Dr. Ricardo Sosa (rdsosam@itesm.mx)
  • 30. Dr. Ricardo Sosa (rdsosam@itesm.mx)
  • 31. Dr. Ricardo Sosa (rdsosam@itesm.mx)
  • 32. After you add a curve, select it with: Rhino.SelectObject(curveID) Then apply the command: Rhino.Command"_Pipe " & 1.0 & " Enter " & 1.0 & " Enter" Dr. Ricardo Sosa (rdsosam@itesm.mx)
  • 33. Due next class… Do somethinginteresting of yourown! Dr. Ricardo Sosa (rdsosam@itesm.mx)