You are on page 1of 162

FOR VERSION 0.6.

0007 - CHINESE EDITION


BY ANDREW PAYNE & RAJAA ISSA

GRASSHOPPER
PRIMER

,
,
,

,
,

The Grasshopper Primer, Second Edition for version 0.6.0007


Copyright 2009 All Rights Reserved


Grasshopper Rajaa Issa
Rajaa Robert McNeel and Associates
Rhino ArchCut PanelingTools
70
Scripting
Grasshopper 0.6.0007
Grasshopper Grasshopper

FLUX
Architecture in a Parametric LandscapeCalifornia College of
the Arts

Grasshopper Rajaa Issa Gil Akos Grasshopper


VB.net Scripting

http://www.grashopper.rhino3d.com

Andrew Payne
LIFT architects
www.liftarchitects.com
Rajaa Issa
Robert McNeel and Associates
http://www.rhino3d.com/

Shaper3d Grasshopper
Grasshopper
()
Jessesn/
Shaper3d
http://bbs.shaper3d.cn
Grasshopper
http://g.shaper3d.cn

1
2
3
4
5
6

Grasshopper

1
2
8
11
13
18

7
7.1
7.2
7.2
7.3
7.4
7.5

21
21
23
25
27
29
32

8
8.1
8.2
8.3
8.4

The Garden of Forking Paths

Excel

36
40
43
46
48

9
9.1
9.2
9.3

/
Point Attractors Vector/Scalar Mathematics ()
Point Attractors Vector/Scalar Mathematics ()

53
55
56
61

10

10.1

67
72

11
11.1
11.2
11.3
11.4

74
76
79
84
89

12

92

13

93

93
93
95
96
97

14
Visual Basic DotNET
14.1
14.2
14.3
14.4
14.5
14.6
14.7
14.8
14.9
14.10
14.11 Grasshopper
14.12 Grasshopper
14.13 /

100
100
100
100
101
103
104
104
106
107
110
113
114
116

15
15.1
15.2
15.3
15.4
15.5
15.6
15.7
15.8
15.9
15.10
15.11
15.12
15.13

Rhino .NET SDK

NURBS

OnNurbsCurve
OnCurve
OnNurbsSurface
OnSurface
OnBrep

118
118
118
121
123
124
124
126
130
132
137
138
147
148

16

155

13.1
13.2
13.3
13.4
13.5

http://g.shaper3d.cn

Getting Started

Grasshopper
Grasshopper http://Grasshopper.rhino3d.com/. Download

Save Target As

Run Rhino4 sr4b

For plugin version 0.6.0007

http://g.shaper3d.cn

The Interface*

Rhino Grasshopper
Grasshopper

Rhino

A. The Main Menu Bar


B file-browser control windows

Rhino Grasshopper Rhino


Undo Ctrl+X, Ctrl+S
Del

B. File Browser Control

* Source: RhinoWiki
http://en.wiki.mcneel.com/default.aspx/McNeel/ExplicitHistoryPluginInterfaceExplained.html
2

For plugin version 0.6.0007

http://g.shaper3d.cn

C. Component Panels
"Params"
"Curves"

Grasshopper

D The Window Title Bar:


windows

Rhino

Grasshopper
_Grasshopper

For plugin version 0.6.0007

http://g.shaper3d.cn

E The Canvas Toolbar:

View

1.
2.
Photoshopwindows

"Load from Rhino"Rhino


2D
Rhino

3.
4.
Photoshop

5.
6.
7.
8.
9.Grasshopper Rhino

10

11.

12. Grasshoper Rhino


13. Grasshopper

14. View

For plugin version 0.6.0007

http://g.shaper3d.cn

F: The Canvas

B
C

D
E /

G: UI Widgets

For plugin version 0.6.0007

http://g.shaper3d.cn

View /

H: The Status Bar

Grasshopper
http://Grasshopper.rhino3d.com Grasshopper

The Remote Control Panel:

Grasshopper

For plugin version 0.6.0007

http://g.shaper3d.cn

Viewport Preview Feedback:

a)
b)
c)
d)

Rhino

For plugin version 0.6.0007

http://g.shaper3d.cn

Grasshopper Objects*Grasshopper

Grasshopper Definition Objects Grasshopper


Grasshopper
Parameters
Components

Grasshopper

C
D
E

* Source: RhinoWiki
For plugin version 0.6.0007
8
http://en.wiki.mcneel.com/default.aspx/McNeel/ExplicitHistoryPluginObjectsExplained.html

http://g.shaper3d.cn

Data Inheritance

Component Parts

A
B
C

Using Context Popup Menus

For plugin version 0.6.0007

http://g.shaper3d.cn

Using Context Popup Menus

Rhino
Rhino
/

R 1

10

For plugin version 0.6.0007

http://g.shaper3d.cn

Persistent Data Management*

(
)
Vector

Vector

Single Multiple

Grasshopper Rhino

* Source: RhinoWiki
http://en.wiki.mcneel.com/default.aspx/McNeel/ExplicitHistoryPersistentDataRecordManagement.html

For plugin version 0.6.0007

11

http://g.shaper3d.cn

Enter

12

For plugin version 0.6.0007

http://g.shaper3d.cn

Volatile Data Inheritance*

(
)
Surface Point
Point

* Source: RhinoWiki
http://en.wiki.mcneel.com/default.aspx/McNeel/ExplicitHistoryVolatileDataInheritance.html
For plugin version 0.6.0007

13

http://g.shaper3d.cn

PtGrid YPoint APoint B


++

14

For plugin version 0.6.0007

http://g.shaper3d.cn

Shift

ADD

CTRL"REM"

For plugin version 0.6.0007

15

http://g.shaper3d.cn

16

For plugin version 0.6.0007

http://g.shaper3d.cn

Grasshopper Params Special


subcategory Receivers
Receivers
Receiver "selected"
"always" "never"

Receiver

Receiver 1

For plugin version 0.6.0007

17

http://g.shaper3d.cn

Data Stream Matching*

Data matching

A B

A B Grasshopper 3

Shortest List

Longest List

Cross Reference

* Source: RhinoWiki
http://en.wiki.mcneel.com/default.aspx/McNeel/ExplicitHistoryDataStreamMatchingAlgorithms.html
For plugin version 0.6.0007
18

http://g.shaper3d.cn

X,Y,Z
X : {0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0}
Y : {0.0, 1.0, 2.0, 3.0, 4.0}
Z : {0.0, 1.0}

Longest List Y,Z X

For plugin version 0.6.0007

19

http://g.shaper3d.cn

"Cross Reference" XYZ 10X5X2=100

20

For plugin version 0.6.0007

http://g.shaper3d.cn

Scalar Component Types

A) Constants
B) Expressions
C) Intervals
D) Operators
E) Polynomials
F) Trigonometry
G) Utility (Analysis) []

7.1 Operators

Scalar_operators.ghx

For plugin version 0.6.0007

21

http://g.shaper3d.cn


Params/Special/ Numeric Slider -

Right click the slider to set:

Lower limit: 0.0

Upper limit: 100.0



50

(Cntrl+C)(Cntrl+V)

Params/Primitive/Integer-

1

2

Integer component
Post-it









Scalar/Operators/Add-
Add A
B
Params/Special/Panel-Post-it
R Post-it
Post-it

Subtraction

Multiplication

Division

Modulus

Power

A

B

5 Post-it
Post-it

22

For plugin version 0.6.0007

http://g.shaper3d.cn

7.2 Conditional Statements

Scalar Operators 4
0.6.0007
Equality, Similarity, Larger Than, Smaller
Than

:
Conditional Statements.ghx.

A) Equality
List A List B
Ture False
Longest List

B) Similarity Equality
List A List B
Similarity

For plugin version 0.6.0007

23

http://g.shaper3d.cn

C) Larger Than List A List B


>>=
D) Smaller Than Larger Than List A List B
<<=

24

For plugin version 0.6.0007

http://g.shaper3d.cn

7.2 Range vs. Series vs. Interval(

Scalar_intervals.ghx
.

0 1.
10 11
0 1. 11 10

3
Series-S 10
1 10 11.
10 series 1
10

For plugin version 0.6.0007

25

http://g.shaper3d.cn

Interval Interval
Range
Range 0 Interval
A B
1020 Interval 10.0 20.0
Interval Range D Interval
Range Range 10
10 20 11 interval,
Scalar/Interval tab. Interval,

26

For plugin version 0.6.0007

http://g.shaper3d.cn

7.3 Functions & Booleans

911 10

.
True()
False()True()
False()
If/Else

Grasshopper

X
Scalar/Expression/F1. F x
5 5 r
5 r
Dispatch p
Dispatch
Dispatch L Dispatch P
Dispatch A Dispatch
B x 5
Circle
Curve/Primitive/Circle
Dispatch A Dispatch

For plugin version 0.6.0007

27

http://g.shaper3d.cn

Dispatch
B

N-sided Polygon
(Curve/Primitive/Polygon) Dispatch B Polygon
R number slider 5 number
slider 5
If/Else

If_Else test.ghx

28

For plugin version 0.6.0007

http://g.shaper3d.cn

7.4 Functions & Numeric Data(


)

Davia Rutten Rhinoscript101


Rhinoscript
http://en.wiki.mcneel.com/default.aspx/McNeel/Rhinoscript101.html
Source File Function_spiral.ghx

Logic/Sets/Range Range

Params/Special/Slider

o
Name: Crv Length
o
Slider Type: Floating Point (this is set by defualt)
o
Lower Limit: 0.1
o
Upper Limit: 10.0
o
Value: 2.5

o
Name: Num Pts on Crv
o
Slider Type: Integers
o
Lower Limit: 1.0
o
Upper Limit: 100.0
o
Value: 100.0

Crv Length Range D

Num Pts on Crv Range N


101 0 5

Logic/Script/F1 Function
Function F Expression Editor

For plugin version 0.6.0007

29

http://g.shaper3d.cn

Expression Editor
o
x*sin(5*x)

Errors No syntax
errors detected in expression
o

30

OK

Function Ctrl+C () Ctrl+V ()


Function F Expression Editor
Expression Editor
o
x*cos(5*x)

cos sin
o OK
Range R Function X
Range 101 Function
Function
r
Vector/Point/Point XYZ Point XYZ
Function r Point X
Function r Point Y
Range R Point Z
Rhino

Curve/Spline/Curve Curve
Point Pt Curve V
Curve D
Curve degree 1
3 Bezier

For plugin version 0.6.0007

http://g.shaper3d.cn

: Zach Downey :
http://www.designalyze.com/2008/07/07/generating-a-spiral-in-rhinos-Grasshopper-plugin/

For plugin version 0.6.0007

31

http://g.shaper3d.cn

7.5 Trigonometric Curves(


)

Function
Grasshopper scalar.,
(sine)cosinetangent
Theta

1822 Joseph
Fourier,
Fourier analysis.

slider
Grasshopper Source Files
Trigonometric_curves.Ghx

definition:

Params/Special/Slider -

Name: Num Pts on Curve

Slider Type: Integers

Lower Limit: 1

Upper Limit: 50

Value: 40


Name: Wave Length

Slider Type: Integers

Lower Limit: 0

Upper Limit: 30

Value: 10


Name: Frequency

Slider Type: Integers

Lower Limit: 0

Upper Limit: 30

32

For plugin version 0.6.0007

http://g.shaper3d.cn






Value: 12
Logic/Sets/Range - Range
Wave Length Range D
Frequency Range D
Num Pts on Curve Range N

definition
0-10 0-12







Scalar/Trigonometry/Sine - Sine
Range-R Sine-x
Vector/Point/Point XYZ - Point XYZ
Range-R Point XYZ x
Sine-y Point XYZ-y
Rhino Range
Point x
Point y
Sine , y ,




Curve/Spline/Curve - Interpolated Curve


Point Pt Curve V

Num Pts on Curve Wave Length


Frequency

For plugin version 0.6.0007

33

http://g.shaper3d.cn

34

Params/Special/Slider

o
Name: Amplitude
o
Slider Type: Floating Point
o
Lower Limit: 0.1
o
Upper Limit: 5.0
o
Value: 2.0
Scalar/Operators/Multiplication Multiplication
Amplitude Multiplication A
Sin y Multiplication B
Multiplication r Point XYZ Y
Amplitude Sine
Sine Y
Amplitude
Vector/Point/Point XYZ Point XYZ
Range R Point XYZ X
Curve/Primitive/Line Line
Point Pt Line B
Point Pt Line A
x Sine
x Line x
Sine

For plugin version 0.6.0007

http://g.shaper3d.cn

sine Sine
Cosine Tangent Cosine Tangent
Scalar/Trigonometry
: David Fano :
http://designreform.net/2008/06/01/rhino-3d-sine-curve-explicit-history/

For plugin version 0.6.0007

35

http://g.shaper3d.cn

The Garden of Forking Paths

Grasshopper 0.6.00xx parameter


Grasshopper

David Rutten

path{0}path
{0}01 2

path

36

For plugin version 0.6.0007

http://g.shaper3d.cn

Rhino
Grasshopper curve Divide Curve
(Curve/Division/Divide Curve) 20 21
Polyline (Curve/Spline/Polyline),

0.5 Grasshopper Polyline


42
Polyline 0.5
Grasshopper

Grasshopper
Polyline 0.600xx
Grasshopper Polyline
20
Parameter Viewer (Params/Special/Param
Viewer)
path{0;0} path{0;1}

For plugin version 0.6.0007

37

http://g.shaper3d.cn

Grasshopper
Grasshopper
Logic/tree
Flatten Tree (Logic/Tree/Flatten Tree)
0.5

Flatten

38

For plugin version 0.6.0007

http://g.shaper3d.cn

Grasshopper Polyline V
Flatten Parameter

Viewer

:
Rhino Curve Paths_base file.3dm.
Curve Paths.ghx

For plugin version 0.6.0007

39

http://g.shaper3d.cn

8.1 &
Grasshopper
()

Grasshopper
List
Logic/Lists
:
List Management.ghx

40

For plugin version 0.6.0007

http://g.shaper3d.cn

Series 0 1 10.
Series Post-it 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0,
9.0.
:
Post-it Post-it

A) List Item (Logic/List/List Item)

0 1 2
-5
Series-S List Item-L List Item-i
5List Item
5.0
B) List Length (Logic/List/List Length)
Series-S List Length-L

C) Reverse List (Logic/List/Reverse List)

D) Shift (Logic/List/Shift List)


Series-S Shift-L Shift-S
shift
-1 1
1Wrap Shift-W
True()False()

For plugin version 0.6.0007

41

http://g.shaper3d.cn

shift +1

E)
Split List
Split List
A - 0.0, 1.0, 2.0, 3.0, 4.0 B - 5.0, 6.0, 7.0,
8.0, 9.0
F) Cull Nth (Logic/Sets/Cull Nth) N N
Cull Nth-N
2 Cull Nth Cull Nth-L
0.0, 2.0, 4.0, 6.0, 8.0
3 Cull Nth 0.0, 1.0, 3.0, 4.0, 6.0, 7.0,
9.0
G) Cull Pattern (Logic/Sets/Cull Pattern) Cull Nth
Pattern
Ture()False()

0.0, 1.0, 4.0, 5.0, 8.0, 9.0.

42

For plugin version 0.6.0007

http://g.shaper3d.cn

8.2

Weaving Data
Grasshopper
Weave Weave
Logics/Lists/Weave
:
Weave Pattern.ghrx

Grasshopper :

Logic/List/Weave Weave
P
0 1 Weave

Weave Input Manager

For plugin version 0.6.0007

43

http://g.shaper3d.cn

Params/Primitive/Integer
Manage Integer Collection""

0, 1, 2

44

Params/Primitive/String String
t String Manage String Collection "
"

For plugin version 0.6.0007

http://g.shaper3d.cn

5
L0:A, L0:B, L0:C, L0:D, L0:E. L0
0

Ctrl+C () and Ctrl+V ()

L1:A,
L1:B, L1:C, L1:D, L1:E
L2:A,
L2:B, L2:C, L2:D, L2:E
Weave-P
Weave-0
Weave-1
Weave-2
Params/Special/Post-it Panel Post-it Panel
Weave-W Post-it Panel
Post-it Panel
0
1 2
0

For plugin version 0.6.0007

45

http://g.shaper3d.cn

8.3

Shifting Data
8.1 Shift
David RuttenGrasshopper
shift

http://en.wiki.mcneel.com/default.aspx/McNeel/ExplicitHistoryShiftExample.html
:
Shift Circle.ghx

Curve/Primitive/Circle CNR Circle CNR (Center, Normal, and Radius)

Circle-C

Rhino "0,0,0"

Circle-R 10.0

46

For plugin version 0.6.0007

http://g.shaper3d.cn

Vector/Constants/Unit Z Unit Z
F 10.0
X Form/Euclidean/Move Move
Unit Z-V Move-T
Circle-C Move-G
000 10
Move 10

Curve/Division/Divide Curve Divide Curve


Circle-C Divide-C
Move-G Divide-C
Params/Special/Slider

Slider Type: Integers


Lower Limit: 1.0
Upper Limit: 30.0
Value: 30.0
Divide Curve-N
30
Logic/List/Shift List Shift List
Divide Curve-P Shift ListL
Params/Special/Slider

Slider Type: Integers


Lower Limit: -10.0
Upper Limit: 10.0
Value: 10.0
Shift ListS
Shift List-W True
10 Warp True

Curve/Primitive/Line Line
Divid CurveP LineA
Shift-L Line-B
Shift
Shift Shift

For plugin version 0.6.0007

47

http://g.shaper3d.cn

8.4 Excel
Grasshopper

:
dfinition Stream Contents_Excel.ghx

Range (Logic/Sets/Range)
0.0 10.0 Range-N 100
0.0 10.0 101
Graph Mapper (Params/Special/Graph Mapper)
Graph Mappper type Linear Range-R Graph
Mapper Post-it Panel Graph
Mapper
Graph Mapper linear Post-it Panel
Graph Mapper Square
Root

Post-it Panel Stream


Contents

C:/Tutorials/Exporting

48

For plugin version 0.6.0007

http://g.shaper3d.cn

Data/Stream_Contents.csv
Text Files (.txt), Comma Separated Values (.csv), Data Files (.dat)
Excel CSV
CSV CSV
row

Microsoft Excel 2007 Excel

(Get
External Data from Text)

(Text Import Wizard) CSV


Stream_Contents.csv Excel

For plugin version 0.6.0007

49

http://g.shaper3d.cn

CSV

50

For plugin version 0.6.0007

http://g.shaper3d.cn

Excel Excel
//

A1 101
A Grasshopper Post-It Panal Grasshopper
GRASSHOPPER CSV
GRASSHOPPER Graph Mapper
Sine
Post-it Panel

For plugin version 0.6.0007

51

http://g.shaper3d.cn

Microsoft Excel

(Refresh All)
CSV Excel A

A1 A101 A1 shift A101


(Line
Chart)

(Insert)

Graph Mapper
Grasshopper
Excel
(Refresh
All)

Excel

52

For plugin version 0.6.0007

http://g.shaper3d.cn

Vector Basics()

A B
B A A B

Rhino XYZ

Rhino

For plugin version 0.6.0007

53

http://g.shaper3d.cn

Point XYZ (Vector/Point/Point XYZ) 000


Point Pt Move G
Unit XUnit Y Unit Z
(Vector/Constants) XYZ
UnitVector
Unit Vector Move T shift
Rhino XYZ

Line (Curve/Primitive/Line) Move G Line


A Point Pt Line B Unit Vector

Source Files UnitVectors.ghx

54

For plugin version 0.6.0007

http://g.shaper3d.cn

9.1 Point/Vector Manipulation /

Grasshopper Point/Vector

Vector/Point/Distance

A B

Vector/Point/Decompose

XYZ

Vector/Vector/Angle

Vector/Vector/Length

Vector/Vector/Decompose

XYZ

Vector/Vector/Summation

1 A
2 B

Vector/Vector/Vector2pt

Vector/Vector/Reverse

Vector/Vector/Unit Vector

Vector/Vector/Multiply

For plugin version 0.6.0007

55

http://g.shaper3d.cn

9.2 Using Vector/Scalar Mathematics with Point Attractors


(Scaling Circles)
Point Attractors Vector/Scalar Mathematics (
)

Source Files Attractor_2pt_circles.ghx

56

For plugin version 0.6.0007

http://g.shaper3d.cn

Params/Special/Numeric Slider

o Slider Type Integers


o Lower Limit 0.0
o Upper Limit 10.0
o Value 10.0
Vector/Point/Grid Rectangular Rectangular Point Grid
Pt Grid X
Pt Grid Y
Pt Grid S
Rectangular Point Grid P
000
X Y 10.0.
20
X Y S

Params/Geometry/Point Point
implicit
xyz
Rhino

Rhino Point
xy
attractor point
Grasshopper
Point Set One Point
Rhino attractor point
attractor point
attractor point .
Vector/Point/Distance Distance
attractor point Distance A
rectangular Grid Point G Distance B

For plugin version 0.6.0007

57

http://g.shaper3d.cn

Distance
D attractor point

58

Scalar/Operators/Division Division
Distance D Division A
Params/Special/Numeric Slider numeric slider

o
Name: Pt1 Influence
o
Slider Type: Floating Point
o
Lower Limit: 0.0
o
Upper Limit: 100.0
o
Value: 25.0
Pt1 Influence Division B

Circle

Scalar/Utility/Minimum Minimum
Division R Minimum A
Params/Special/Numeric Slider Numeric Slider

o
Name: Falloff
o
Slider Type: Floating Point
o
Lower Limit: 0.0
o
Upper Limit: 30.0
o
Value: 5.0
Falloff Minimum B
Curve/Primitive/Circle CNR Circle CNR (Center, Normal, and
Radius)

Rectangular Point Grid G Circle C


Minimum R Circle R

For plugin version 0.6.0007

http://g.shaper3d.cn

Rectangular Point Grid Preview

attractor point
attractor point

Attractor Point parameter, Distance component, Pt 1 Influence


slider, Division component, Falloff slider, Minimum Ctrl-c ()
Ctrl-v ()

point attractor
Rhino

Rhino "Point"
Rhino
XY
duplicated Point "Set One Point"
, Rhino attractor point
2 rectangular Point Grid
2 Minimum
Addition
Scalar/Operators/Addition Addition
Minimum R Addition A

For plugin version 0.6.0007

59

http://g.shaper3d.cn

Minimum R Addition B
Addition R Circle R (:
)

Falloff sliders 2 Minimum


Pt Influence Falloff
:
, David Fano's :
http://designreform.net/2008/07/08/grasshopper-patterning-with-2-attractor-points/

60

For plugin version 0.6.0007

http://g.shaper3d.cn

9.3 Using Vector/Scalar Mathematics with Point Attractors


(Scaling Boxes)
Point Attractors Vector/Scalar Mathematics (
)

Vector/Scalar Mathematics

Grasshopper shader

Source Files Color Boxes.ghx

For plugin version 0.6.0007

61

http://g.shaper3d.cn

Params/Special/Numeric Slider 2 sliders

slider
o Slider Type: Integers
o Lower Limit: 0.0
o Upper Limit: 10.0
o Value: 3.0

slider
o
Slider Type: Integers
o
Lower Limit: 0.0
o
Upper Limit: 25.0
o
Value: 25.0

Vector/Point/Grid Rectangular 1 rectangular Point Grid

slider Point Grid X Y

slider Point Grid S


x y

Logic/Sets/Series 1 Series
slider Series N
slider Series C
z
xy 3
7
7 z
series count
Series C Expression Tab
Expression editor (C*2)+1
Series C 1
3 Series count 7.
Vector/Constants/Unit Z Unit Z vector
Series S Unit Z F
Unit Z vector 7 z
25 slider

62

X Form/Euclidean/Move

For plugin version 0.6.0007

http://g.shaper3d.cn

Point Grid G Move G


Unit Z V Move T
Rhino

longest list cross reference

Surface/Primitive/Center Box Center Box


Move G the Center Box B
Point Grid Move component Preview
.

Params/Geometry/Point Point
Point Attractor Pt
Rhino
Rhino Point
Grasshopper Attractor Pt Set One Point
Rhino
X Attractor Pt
Grasshopper
Vector/Point/Distance Distance
Attractor Pt Distance A
Move G Distance B
Distance D
Attractor Pt
.
Scalar/Operators/Division Division
Distance D Division A
Params/Special/Numeric Slider Numeric Slider

o
Name: Scale Factor
o
Slider Type: Integers
o
Lower Limit: 0.0
o
Upper Limit: 25.0
o
Value: 25.0
Division B

For plugin version 0.6.0007

63

http://g.shaper3d.cn

X Form/Affine/Scale Scale
Center Box B Scale G
Division R Scale F
Center Box Preview

Rhino box attractor


.

box

Logic/List/Sort List Sort List


box attractor box

Logic/List/List Item List Item


Sort List L List Item L
List Item I 0.0

Logic/List/List Length List Length


Sort List L List Length L

64

Logic/List/List Item- List Item


Sort List L the List Item L
List Length L List Item I
List Item E
Grasshopper
0 100
0 99. List Item
I 1
List Item I Expression Editor

For plugin version 0.6.0007

http://g.shaper3d.cn

i-1

List Item E
attractor .

Params/Special/Gradient Gradient
List Item E () the Gradient
L0
List Item E () the Gradient
L1
Division R the Gradient T
TL0
box attractor L1
Gradient T
box

Vector/Color/Create Shader Create Shader


Gradient Shader Kd
Shader

Kd: Shader
0-255
Ks: RGB
Ke: Shader emmissivity Shader

T: Shader
S: Shader 0 100
Gradient Shader
Gradient Box

Gradient
Gradient Gradient
spectrum

Params/Special/Custom Preview Custom Preview


Scale G Custom Preview G
Shader S Custom Preview S
scale Preview

For plugin version 0.6.0007

65

http://g.shaper3d.cn

rhino attractor
box

66

For plugin version 0.6.0007

http://g.shaper3d.cn

10

Curve Types


Grasshopper Primitive Curve

Grasshopper Rhino NURBS


Grasshopper spline

Source Files
Curve Types.3dm 6
x-y
Grasshopper

For plugin version 0.6.0007

67

http://g.shaper3d.cn

Grasshopper
Source Files Curve
Types.ghx

RhinoSet
Grasshopper
Point
Point Set
MultiplePoints.


Grasshopper 6 x
Grasshopper Point .

A) NURBS Curves
(Curve/Spline/Curve)
B
NURBS Rhino

NURBS
Degree Knot Weight
NURBS

http://en.wikipedia.org/wiki/NURBS.
URBS Curve V
Rhino
NURBS Curve D
1-11
David Rutten Rhinoscript 101 nurbs

68

For plugin version 0.6.0007

http://g.shaper3d.cn

NURBS Knot() Degree()


1 NURBS polyline

2 NURBS
2 NURBS

3 NURBS NURBS Rhino

Rhino 4 NURBS

5 3

7 9 Rhino 11

curve D
NURBS Curve-P Inputt
. False NURBS ,True

For plugin version 0.6.0007

69

http://g.shaper3d.cn

NURBS NURBS C
L D
0 X

B) Interpolated Curves (Curve/Spline/Interpolate)


Interpolated Curves Curve

.
NURBS Curve
.

Interpolated Curves. V-Input


Nurbs Curve V ,
Interpolated
Curves
. N
1
URBS Curve
D- input

P-input

C, L D outputs

C) Kinky Curves (Curve/Spline/Kinky Curve)


Kinky Curve Interpolated Curves Interpolated
Curves KinkyCurve
numeric slider Kinky Curve A
A radians
A expression

D) Polyline Curves

(Curve/Spline/Polyline)
Rhino Polyline curve
Polyline curve
1
NURBS Polyline
curve Polyline
curve

1 NURBS

Interpolated Curve

70

For plugin version 0.6.0007

http://g.shaper3d.cn

Polyline curve
V
C


Grasshopper

E) Poly Arc
(Curve/Spline/Poly
Arc)
Poly-arc
Polyline curve

For plugin version 0.6.0007

71

http://g.shaper3d.cn

10.1 Curve Analytics


Grasshopper

Component

72

Location

Description

Example

Curve/Analysis/Center

Curve/Analysis/Closed

Curve/Analysis/Closest
Point

Curve/Analysis/End Points

Curve/Analysis/Explode

Curve/Utility/Join Curves

Curve/Analysis/Length

Curve/Division/Divide
Curve

Curve/Division/Divide
Distance

For plugin version 0.6.0007

http://g.shaper3d.cn

Curve/Division/Divide
Length

Curve/Utility/Flip

Curve/Utility/Offset

Curve/Utility/Fillet

Curve/Utility/Project

Brep (Brep
Rhino polysurface)

Intersect/Region/Split with
Brep(s)

Brep

Intersect/Region/Trim
with Brep(s)

Breps Ci(
) Co()

Intersect/Region/Trim
with Region(s)

Region
Ci() Co ()

Intersect/Boolean/Region
Union

Intersect/Boolean/Region
Intersection

Intersect/Boolean/Region
Difference

For plugin version 0.6.0007

73

http://g.shaper3d.cn

11

Surface Types*

Rhino
NURBS NURBS
Rhino

s
NURBS NURBS

s
s

NURBS U V
NURBS

Grasshopper NURBS Rhino


Grasshopper Rhino
Grasshopper
Grasshopper
Grasshopper

* Source: Rhinoscript 101 by David Rutten


http://en.wiki.mcneel.com/default.aspx/McNeel/RhinoScript101

74

For plugin version 0.6.0007

http://g.shaper3d.cn

Grasshopper NURBS
NURBS

Grasshopper
McNeel
Rhino Brep
Brep Rhino NURBS
NURBS
Brep NURBS
Grasshopper
Brep Brep
Numbers Integers, Colors Vectors, Arcs Circles

Curve
Number ( Curve )
Curve
Interval ( Curve )
Surface
Interval2D ( Surface uv )
String
Number ( string ,)
Interval2D Number ( interval area )

11.1 Surface Connect

David Fano Design Reform


Sweep2Rail, Surface Offset,
SurfaceDivision ~ Rhino Source
FileSurfaceConnect.3dm2
1

For plugin version 0.6.0007

75

http://g.shaper3d.cn

:, Grasshopper SurfaceConnect.ghx
Source Files

76

For plugin version 0.6.0007

http://g.shaper3d.cn

Surface/Freeform/Sweep2Rail - Sweep 2 Rails

Sweep2Rail R1 "Set one Curve"

Sweep2Rail R2 "Set one Curve"

Sweep2Rail S "Set one Curve"

section curve

.
Surface/Freeform/Offset - Surface Offset
Sweep2Rail S Offset S
Params/Special/Slider - Numeric Slider
slider
o
Name: Surface Offset
o
Slider Type: Floating Point
o
Lower Limit: 0.0
o
Upper Limit: 10.0
o
Value: 10.0
slider Surface Offset D
10

Surface/Utility/Divide Surface - Divide Surface


Sweep2Rail S Divide Surface S

For plugin version 0.6.0007

77

http://g.shaper3d.cn

Sweep2Rail
Divide Surface UV 10 Divide Surface
10 ,
ISO
Surface Offset S Divide Surface S

Params/Special/Slider - numeric sliders


slider
o Name: U Divisions
o Slider Type: Integers
o Lower Limit: 0.0
o Upper Limit: 100.0
o Value: 15.0
slider
o
Name: V Divisions
o
Slider Type: Integers
o
Lower Limit: 0.0
o
Upper Limit: 100.0
o
Value: 25.0
U Divisions Divide Surface U
V Divisions Divide Surface V

Curve/Primitive/Line - Line
Divide Surface P Line A
Divide Surface P Line B

78

Surface/Freeform/Pipe - Pipe
Line L Pipe C
Params/Special/Slider - Numeric Slider
slider
o Name: Pipe Radius
o Slider Type: Floating Point
o Lower Limit: 0.0
o Upper Limit: 2.0
o Value: 0.75
Pipe Radius Pipe R

For plugin version 0.6.0007

http://g.shaper3d.cn

11.2 Paneling Tools


McNeel Rhino paneling tools
Grasshopper component
Paneling Tools ,, interval
, GH
Paneling Tools
http://en.wiki.mcneel.com/default.aspx/McNeel/PanelingTools.html.
GH

Grasshoppper , GH
Paneling Tool.ghx, Source Files

For plugin version 0.6.0007

79

http://g.shaper3d.cn

GH Rhino
Panel Tool_base.3dm ,,
,

Params/Geometry/Curve Curve

Curve Set Multiple Curves

Rhino

Grasshopper Rhino

Surface/Freeform/Loft Loft
Curve Loft L
Loft O Rhino

: GH
,
Flip
Flip

Surface/Utility/Flip Flip
Loft L Flip S
Params/Geometry/Surface Surface
Flip S Surface
Surface Reparameterize

Reparameterize

Scalar/Interval/Divide Interval2 Divide Two Dimensional Interval

Divide Interval I "Manage Interval Collection"

80

For plugin version 0.6.0007

http://g.shaper3d.cn

u:{0.0 To 0.0} v:{0.0 To 0.0} UV


0 to 1

U-End 1.0
U-End 1.0

Interval Collection Manager OK


Divide Interval I U V

Params/Special/Slider - slider
slider
o
Name: U Interval
o
Slider Type: Integers
o
Lower Limit: 5.0
o
Upper Limit: 30.0
o
Value: 10.0

slider
o
Name: V Interval
o
Slider Type: Integers
o
Lower Limit: 5.0
o
Upper Limit: 30.0
o
Value: 10.0
U Interval slider Divide Interval U
V Interval slider Divide Interval V

For plugin version 0.6.0007

81

http://g.shaper3d.cn

Xform/Morph/Surface Box - Surface Box


Surface Surface Box S
Divide Interval S Surface Box D
Curve, Loft, and Surface
Preview
slider
100

U V
10*10
100
U V slider

Params/Geometry/Geometry - Geometry
Geometry "Set Multiple Geometries"
Rhino spandrel panelmullion glazing panel

Surface/Primitive/Bounding Box - Bounding Box


Geometry Bounding Box C
Bounding Box Bounding Box

Surface Box
Bounding Box BoxMorph Brep
BoxMorph

Bounding Box U boolean True


bounding box 3 Brep bjects
box
Surface/Analysis/Box Components - Box Components
Bounding Box-B Box Components B
Box Components Z Surface Box H

82

Xform/Morph/Box Morph - Box Morph


Pattern Geometry Box Morph G
Bounding Box B Box Morph R
Surface Box B Box Morph T
Morph Box data matching Cross Reference
Surface Box Preview

For plugin version 0.6.0007

http://g.shaper3d.cn

Morph Box
Windows
Bounding Box 100

U V

11.3 Surface Diagrid


Paneling Tools GH defiinition

Rhino Surface Diagrid.3dm

For plugin version 0.6.0007

83

http://g.shaper3d.cn

Note: , GH Surface Diagrid.ghx,


Source Files

Params/Geometry/Curve Curve

Curve Input Crv1

Input Crv1 Set One Curve

Rhino

Curve Input Crv2

Input Crv2 Set One Curve

Surface/Freeform/Loft Loft

Input Crv1 Loft S

Shift Input Crv2 component Loft S


Rhino

Params/Geometry/Surface Surface

Loft L Surface

Scalar/Interval/ Divide Interval2 Divide Two Dimensional Interval

U V

84

Surface Divide Interval I


Params/Special/Numeric Slider slider
slider

For plugin version 0.6.0007

http://g.shaper3d.cn

Name: Surface Division Number


o
Slider Type: Integers
o
Lower Limit: 0.0
o
Upper Limit: 20.0
o
Value: 12.0
Slider Divide Interval U V
Surface/Utility/Isotrim Isotrim
Surface Isotrim S
Divide Interval S Isotrim D
Loft Surface
slider
slider U V
slider U V
U V slider
Surface/Analysis/Brep Components Brep
Brep Brep

Isotrim S Brep B
o

Param/Special/Parameter Viewer - Parameter Viewer


Brep V Parameter Viewer
Parameter Viewer tree structure
structure 144 path 4
4 List Item
path sub-path

For plugin version 0.6.0007

85

http://g.shaper3d.cn

Logic/List/List Item - 4 List Item


Brep V 4 List Item L
List Item i Integer 0
List Item i Integer 1
List Item i Integer 2
List Item i Integer 3
List Item tree
structure Grasshopper 144 path
path 4 path
4 List Item

Curve/Primitive/Line - Line
List Item E Line A
List Item E Line B
List Item E Line A
List Item E Line B

Surface/Freeform/Pipe - Pipe
Line-L Pipe-C
Shift Line-L Pipe-C
slider pipe
Params/Special/Number Slider slider
slider
o
Name: Pipe Radius
o
Slider Type: Floating Point
o
Lower Limit: 0.0
o
Upper Limit: 1.0
o
Value: 0.05
Pipe Radius slider Pipe-R

Surface/Freeform/4Point Surface 4 Point Surface


List Item-E Point Surface-A
List Item-E Point Surface-B
List Item-E Point Surface-C
List Item-E Point Surface-D
4 Point Surface Pipe Preview

86

For plugin version 0.6.0007

http://g.shaper3d.cn

For plugin version 0.6.0007

87

http://g.shaper3d.cn

11.4 Uneven Surface Diagrid

Graph Mapper

: Grasshopper Source Files Uneven Surface


Diagrid.ghx

Divide Interval Isotrim

88

For plugin version 0.6.0007

http://g.shaper3d.cn

Isotrim-D "Disconnect All"

Isotrim

Scalar/Interval/Interval Components - Interval


Components 4 number

Divide Interval-S Interval Components-I

Params/Special/Graph Mapper - Graph


Mapper
U0 Graph Mapper
shift k U1 Graph Mapper

Graph Mapper graph


bezier Graph
Mapper bezier

UV U Graph Mapper

Isotrim

Logic/List/List Length - List Length


U1 Length-L
Logic/List/Split List Split List
Graph Mappe Split List L
List Length-L Split List-i
Scalar/Interval/Interval 2d two dimensional Interval
Split List-A two dimensional Interva U0
Split List-B two dimensional Interval U1
decomposed interval V0 V1 two dimensional Interval
V0 V1
2 Graph Mapper
two
dimensional interval U Graph Mapper
U bezier decomposed interval
V0 V1 two dimensional interval V0 V1 V
Graph
Mapper v0 v1 v
Isotrim

For plugin version 0.6.0007

89

http://g.shaper3d.cn

two dimensional Interval-I2 Isotrim-D

bezier

90

For plugin version 0.6.0007

http://g.shaper3d.cn

12 An Introduction to Scripting

VB DotNETC#
Grasshopper
DotNET CLR
Rhino
Grasshopper Rhino DotNET SDK
Rhino Grasshopper DotNET
Rhino SDK

Grasshopper

Grasshopper VB DotNET
VB
DotNET Rhino DotNET SDK

For plugin version 0.6.0007

91

http://g.shaper3d.cn

The Scripting Interface

13

13.1
VB DotNet Logic Visual
Basic C#

X:
Y:
Out:
A:

13.2
x y

92

Parameter Name(
):

Run Time Message(
):

For plugin version 0.6.0007

http://g.shaper3d.cn

Disconnect and Disconnect All(


):
Grasshopper

Flatten (
):

List(
):

Type Hint(
):

On NURBS

For plugin version 0.6.0007

93

http://g.shaper3d.cn

13.3

94

For plugin version 0.6.0007

http://g.shaper3d.cn

13.4
out

For plugin version 0.6.0007

95

http://g.shaper3d.cn

13.5

Edit Source

A:
B: Grasshopper_Custom_Script
C: VB.NET
D:

A:
dll DotNET
Rhino dll RMA.openNURBS RMA.Rhino rhino
Grasshopper

96

For plugin version 0.6.0007

http://g.shaper3d.cn

B: Grasshopper_Custom_Script
Grasshopper_Custom_Script

For plugin version 0.6.0007

97

http://g.shaper3d.cn

1. Members(
):
rhino app
doc Rhino
RhnioUtil

2. RunScript(
):

3. Additional methods and Type Declaration (


:)

(doc )
RhUtil Rhino

1 2

98

For plugin version 0.6.0007

http://g.shaper3d.cn

14

Visual Basic DotNET

14.1
VB.NET

14.2 (comment)

VB.NET,
Grasshopper
This is a comment ,i I can write anything i like!
Realy anything

14.3 (Variables)

int32 32

x Int32 10.
20 x VB DotNET

Dim x as Int32 = 10
x 10
x = 20
x 20

Dim x as Double = 20.4

Dim b as Boolean = True


Double, Boolean and String
Dim name as String = Joe

Grasshopper
x:
y:
A:

For plugin version 0.6.0007

99

http://g.shaper3d.cn

14.4
Array and lists
VB.NET

Dim myArray(1) As Integer


myArray (0) = 10
myArray (1) = 20

Dim my2DArray (1,2) As Integer


my2DArray (0, 0) = 10
my2DArray (0, 1) = 20
my2DArray (0, 2) = 30
my2DArray (1, 0) = 50
my2DArray (1, 1) = 60
my2DArray (1, 2) = 70

Dim myArray() As Integer = {10,20}

100

Dim my2DArray(,)As Integer = {{10,20,30},{40,50,60}}

For plugin version 0.6.0007

http://g.shaper3d.cn

VB.NET 9

For plugin version 0.6.0007

101

http://g.shaper3d.cn

14.5
VB.NET

Type

Operator

Description

Mod

^=

*=

/=

\=

+=

-=

&=

<

<=

>

>=

<>

&

And

Not

Or

Xor

102

For plugin version 0.6.0007

http://g.shaper3d.cn

14.6

IF<
>
>

if
Then <
End IF

End If: =(x<y), =(x=x+y)

If x < y Then x = x + y
End If

If x < y Then
x=x+y
End If

Else If Then

Else

If x < y Then
x = x + y End If
Else If x > y Then
x = x y End If
Else
x = 2*x
End If
End If

index

Select Case index


Case 0 index=0
x=x*x
Case 1
x=x^2
Case 2
x = x ^ (0.5)
End Select

14.7

For Next

For < => To <> [Step <>]


for

[/]

For plugin version 0.6.0007

103

http://g.shaper3d.cn

[ Exit For ]
[ ]

[ Continue For ]

[ ]
for ( Next)
Next : for
Next

Next
[ For ]

Dim places_list As New List( of String )


places_list.Add( Paris )
places_list.Add( NY )
places_list.Add( Beijing )

Dim i As Integer
Dim place As String
Dim count As Integer = places_list.Count()

0 count-1 count=3 places_list =2


For i=0 To count-1
place = places_list(i)
Print( place )
Next

ForNext

Dim places_list As New List( of String )


places_list.Add( Paris )
places_list.Add( NY )
places_list.Add( Beijing )
For Each place As String In places_list
Print( place )
Next

While End While

While < >


While

[ ]

104

For plugin version 0.6.0007

http://g.shaper3d.cn

[ Exit While ]

[ ]
[ Continue While ]
[ ]
While

End While

End While
[ While ]

while
Dim places_list As New List( of String )
places_list.Add( Paris )
places_list.Add( NY )
places_list.Add( Beijing )
Dim i As Integer
Dim place As String
Dim count As Integer = places_list.Count()
i=0
While i < count
(i<count)
place = places_list(i)
Print( place )
i=i+1
End While

14.8

For plugin version 0.6.0007

105

http://g.shaper3d.cn

Grasshopper

106

For plugin version 0.6.0007

http://g.shaper3d.cn

14.9
Grasshopper

Sub RunScript(ByVal x As Object, ByVal y As Object)


<your code>
End Sub

Sub End Sub:


RunScript:
():
ByVal x As Object,:

ByRef

ByVal
:

As

Grasshopper RunScript sub


ByVal
/
ByRef

RunScript

Sub

)
Function(

Function AddFunction( ByVal x As Double, ByVal y As Double )


AddFunction = x + y
End Function

rc
Sub AddSub( ByVal x As Double, ByVal y As Double, ByRef rc As Double )
rc = x + y
End Sub

For plugin version 0.6.0007

107

http://g.shaper3d.cn

Dim x As Double = 5.34


Dim y As Double = 3.20
Dim rc As Double = 0.0

rc = AddFunction( x, y ) rc
AddSub( x, y, rc )
rc

108

For plugin version 0.6.0007

http://g.shaper3d.cn

14.10 Recursion

Grasshopper

(C).
(A). Slider
(L)

For plugin version 0.6.0007

109

http://g.shaper3d.cn

DivideAndRotate

110

AllLines ()

For plugin version 0.6.0007

http://g.shaper3d.cn

while

For plugin version 0.6.0007

111

http://g.shaper3d.cn

112

For plugin version 0.6.0007

http://g.shaper3d.cn

14.11 Grasshopper
Grasshopper
1.
2.

10

RunScript 10
DoubleList (of
Double)

RunScript

For plugin version 0.6.0007

113

http://g.shaper3d.cn

14.12 Grasshopper

11a
A: Flatten()List()

B: List() List(
)

114

For plugin version 0.6.0007

http://g.shaper3d.cn

C: 33
Flatten()

VB inside

For plugin version 0.6.0007

115

http://g.shaper3d.cn

14.13 File I/O


VB.NET

x y z

VB

116

For plugin version 0.6.0007

http://g.shaper3d.cn

For plugin version 0.6.0007

117

http://g.shaper3d.cn

15

Rhino .NET SDK

15.1
Rhino .NET SDK OpenNURBS . .NET SDK
. :
http://en.wiki.mcneel.com/default.aspx/McNeel/Rhino4DotNetPlugIns.html
, Rhino SDK .
Grasshopper VB .

15.2 NURBS
Rhino Non-Uniform Rational Basis Spline B NURBS)
NURBS . NURBS
.
(http://en.wikipedia.org/wiki/NURBS)
NURBS . NURBS SDK
.
NURBS . Degree, control points, knots
evaluation rules:

Degree
123 5 . Rhino 1-11 .
:

1 NURBS

Order()= 2 ( = + 1)

2 NURBS .
.
Order() = 3.

Free form 3
NURBS .
Order ()= 4
5

118

For plugin version 0.6.0007

http://g.shaper3d.cn

Control points
NURBS (+1).
.
Weight .
.
( 1), .
Grasshopper .

Knots or knot vector


NURBS . ,
SDK . :
Knot multiplicity
. .
.
Full multiplicity knot .
.
.
Simple knot :
.
Uniform knot vector :
1. = + 1.
2. ,,
..
.
:
= 3
s = 7
= (0,0,0,1,2,3,5,5,5)

= 3
= 7
= (0,0,0,1,1,1,4,4,4)
:
.

For plugin version 0.6.0007

119

http://g.shaper3d.cn

Evaluation rule
. .
,SDK .
. :(m_t(0))
(m_t(0)) .

NURBS
NURBS NURBS . NURBS
U V . Rhino

NURBS . NURBS
.
. NURBS
.

. .
NURBS .

120

For plugin version 0.6.0007

http://g.shaper3d.cn

Polysurfaces
(). UV
. boundary representation ( BRep).
. ,
,, . BReps
.
OnBrep OpenNURBS , Rhino SDK
BReps.

15.3 OpenNURBS Objects Hierarchy


SDK . .
. SDK .
OnObject ( Rhino OnObject)

- OnGeometry ( OnObject)
o OnPoint
 OnBrepVertex
 OnAnnotationTxtDot
o OnPointGrid
o OnPointCloud
o OnCurve (abstaract class)
 OnLineCurve
 OnPolylineCurve
 OnArcCurve
 OnNurbsCurve
 OnCurveOnSurface
 OnCurveProxy
OnBrepTrim
OnBrepEdge
o OnSurface (abstract classt)

For plugin version 0.6.0007

121

http://g.shaper3d.cn







o
o
o
-

OnPlaneSurface
OnRevSurface
OnSumSurface
OnNurbsSurface
OnProxySurface
OnBrepFace
OnOffsetSurface
OnBrep
OnMesh
OnAnnotation

Points and Vectors (not derived from OnGeometry)


o On2dPoint (good for parameter space points)
o On3dPoint
o On4dPoint (good for representing control points with x,y,z and w for
weight)
o On3dVector

- Curves (not derived from OnGeometry)


o OnLine
o OnPolyline (is actually derived from OnPointArray)
o OnCircle
o OnArc
o OnEllipse
o OnBezierCurve
- Surfaces (not derived from OnGeometry)
o OnPlane
o OnSphere
o OnCylinder
o OnCone
o OnBox
o OnBezierSurface
-

122

Miscellaneous
o OnBoundingBox (For objects bounding box calculation)
o OnInterval (Used for curve and surface domains)
o OnXform (for transforming geometry objects: move, rotate, scale, etc.)
o OnMassProperties (to calculate volume, area, centroid, etc)

For plugin version 0.6.0007

http://g.shaper3d.cn

15.4 Class structure


():

Constructor :
.
Public member variables :
. OpenNURBS
m_.
Public member functions :

.
Private members :
.

, auto-complete
. ,.
, auto-complete .
. On3dPoint :

. ,
On3dPoint . :
Use the constructor when you instantiate an instance of the point class
Dim new_pt as New On3dPoint( input_pt )
Use the = operator if the class provides one
Dim new_pt as New On3dPoint
new_pt = input_pt
You can use the New function if available
Dim new_pt as New On3dPoint

For plugin version 0.6.0007

123

http://g.shaper3d.cn

new_pt.New( input_pt )
There is also a Set function sometimes
Dim new_pt as New On3dPoint
new_pt.Set( input_pt )
Copy member variables one by one.
Dim new_pt as New On3dPoint
new_pt.x = input_pt.x
new_pt.y = input_pt.y
new_pt.z = input_pt.z

A bit exhaustive method

OpenNURBS geometry classes provide Duplicate function that is very efficient to use
Dim new_crv as New OnNurbsCurve
new_crv = input_crv.DuplicateCurve()

15.5 Constant vs Non-constant Instances


Rhino .NET SDK . I;
IOn3dPoint. I; On3dPoint.
.
Rhino .NET SDK Rhino C++ SDK . C++
SDK ., DotNET
.

15.6 Points and Vectors


. .:
Class name

Member variables

Notes

On2dPoint

x as Double
y as Double

.
d .
f.

On3dPoint

x as Double
y as Double

On4dPoint

x as Double
y as Double
z as Double
w as Double

Vector Addition:
Dim add_v As New On3dVector = v0 + v1

Vector Subtraction:
Dim subtract_vector As New On3dVector = v0 v1

Vector between two points:

124

For plugin version 0.6.0007

http://g.shaper3d.cn

Dim dir_vector As New On3dVector = p1 p0

Vector dot product (if result is positive number then vectors are in the same direction):
Dim dot_product As Double = v0 * v1

Vector cross product (result is a vector normal to the 2 input vectors)


Dim normal_v As New On3dVector = OnUtil.ON_CrossProduct( v0, v1 )

Scale a vector:
Dim scaled_v As New On3dVector = factor * v0

Move a point by a vector:


Dim moved_point As New On3dPoint = org_point + dir_vector

Distance between 2 points:


Dim distance As Double = pt0.DistanceTo( pt1)

Get unit vector (set vector length to 1):


v0.Unitize()

Get vector length:


Dim length As Double = v0.Length()

For plugin version 0.6.0007

125

http://g.shaper3d.cn

15.7 OnNurbsCurve
nurbs
Dimension 3
Order +1
Control Point
Knot Vector
Curve Type ().

126

For plugin version 0.6.0007

http://g.shaper3d.cn

clamped vs periodic NURBS curve


(clamped curve)(Periodic curve)

NURBS

7 4+ 4

For plugin version 0.6.0007

127

http://g.shaper3d.cn

CV

weights
nurbs 1 nurbs
Gh

128

For plugin version 0.6.0007

http://g.shaper3d.cn

NURBS

For plugin version 0.6.0007

129

http://g.shaper3d.cn

RhUtil name space

15.8 OnCurve
NURBS
NURBS
OnCurve NURBS

Curves Types

OnCurve Derived Types

OnLine

OnLineCurve

OnPolyline

OnPolylineCurve

OnCircle

OnArcCurve or OnNurbsCurve (use GetNurbsForm() member function)

OnArc

OnArcCurve or OnNurbsCurve (use GetNurbsForm() member function)

OnEllipse

OnNurbsCurve (use GetNurbsForm() member function)

130

For plugin version 0.6.0007

http://g.shaper3d.cn

OnBezierCurve

OnNurbsCurve (use GetNurbsForm() member function)

OnEllipse OnPolyline

For plugin version 0.6.0007

131

http://g.shaper3d.cn

15.9 OnNurbsSurface
OnNurbsCurve OnNurbsSurface
3
u v +1

u v
().

132

For plugin version 0.6.0007

http://g.shaper3d.cn

1
0-1

u v

For plugin version 0.6.0007

133

http://g.shaper3d.cn

OnSurface

Gh xy

134

For plugin version 0.6.0007

http://g.shaper3d.cn

For plugin version 0.6.0007

135

http://g.shaper3d.cn

136

For plugin version 0.6.0007

http://g.shaper3d.cn

15
10 OnSurface
OpenNURBS OnSurface
OnSurface OnSurface
Basic Surface Types

OnSurface derived Types


OnSurface

OnPlane

OnPlaneSurface or
OnNurbsSurface (use OnPlane.GetNurbsForm() function)

OnShpere

OnRevSurface or
OnNurbsSurface (use OnShpere.GetNurbsForm() function)

OnCylinder

OnRevSurface or
OnNurbsSurface (use OnCylinder.GetNurbsForm() function)

OnCone

OnRevSurface or
OnNurbsSurface (use OnCone.GetNurbsForm() function)

OnBezierSurface

OnNurbsSurface (use GetNurbsForm() member function)

Here is an example that uses OnPlane and OnCone classes:


OnPlane OnCone

For plugin version 0.6.0007

137

http://g.shaper3d.cn

15
11 OnBrep
(B-Rep) OnBrep

nurbs

nurbs

nurbs
brep brep
bounding a hole

OnBrep
OnBrep brep

138

For plugin version 0.6.0007

http://g.shaper3d.cn

Topology members: describe relationships among different brep parts

brep
OnBrepVertexArray m_V

Array of brep vertices (OnBrepVertex)

OnBrepEdgeArray m_E

Array of brep edges (OnBrepEdge)

OnBrepTrimArray m_T

Array of brep trims (OnBrepTrim)

OnBrepFaceArray m_F

Array of brep faces (OnBrepFace)

OnBrepLoopArray m_L

Array of loops (OnBrepLoop)

Geometry members: geometry data of 3d curves and surfaces and 2d trims

OnCurveArray m_C2

Array of trim curves (2D curves)

CnCurveArray m_C3

Array of edge curve (3D curves)

ONSurfaceArray m_S

Array of surfaces

OnBrep m_F OnBrepFace


OnBrepFace OnSurfaceProxy
OnBrepFace, OnBrepEdge, OnBrepVertex, OnBrepTrim and OnBrepLoop
classes

For plugin version 0.6.0007

139

http://g.shaper3d.cn

OnBrep
brep

brep

140

For plugin version 0.6.0007

http://g.shaper3d.cn

OnBrep brep

OnBrep
OnBrep
brep
brep
OnSurface

o
SumSurface
o
RevSurface
o
PlanarSurface
o
OnSurface

o
OnUtil such as ON_BrepBox, ON_BrepCone, etc.
o
RhUtil such as RhinoCreatEdgeurface or RhinoSweep1
among others.
brep

For plugin version 0.6.0007

141

http://g.shaper3d.cn

OnBrep
brep

brep

142

For plugin version 0.6.0007

http://g.shaper3d.cn

OnBreps
OnGeometry
Trabsform OnXform 4
4 OnXform

OnBrep
OnBrep breps
breps
McNeels wiki DotNET brep
OnBrep
OnBrep brep
bounding box center

For plugin version 0.6.0007

143

http://g.shaper3d.cn

OnBrep
OnBrep OnBrep
OnBrep,BoundingBox()OpenNURBSl
OnBoundingBox brep bounding box

144

For plugin version 0.6.0007

http://g.shaper3d.cn

OnMassProperties

Istrue false
brep brep
OnBrep.IsSolid() brep
OnBrep

For plugin version 0.6.0007

145

http://g.shaper3d.cn

brep

146

For plugin version 0.6.0007

http://g.shaper3d.cn

15.12
OnXform

OnXform m_xform 4x4 class

OnXform

For plugin version 0.6.0007

147

http://g.shaper3d.cn

15.13 Global utility functions

CLASS Rhino.NET SDK OnUtil RhUtil

OnUtil
OnUtil

148

For plugin version 0.6.0007

http://g.shaper3d.cn

OnUtil

OnUtil intersections
OnUtil

ON_Intersect 11
IOnLineI
Intersected geometry

output

IOnLine with IOnArc

Line parameters (t0 & t1) and Arc points (p0 & p1)
(t0 & t1)(p0 & p1)

IOnLine with IOnCircle

Line parameters (t0 & t1) and circle points (p0 & p1)
(t0 & t1)(p0 & p1)

IOnSphere with IOnShere

OnCircle

IOnBoundingBoc with IOnLine

Line parameters (OnInterval)

IOnLine with IOnCylinder

2 points (On3dPoint)

IOnLine with IOnSphere

2 points (On3dPoint)

IOnPlane with IOnSphere

OnCircle

IOnPlane with IOnPlane with IOnPlane

On3dPoint

IOnPlane with IOnPlane

OnLine

IOnLine with IOnPlane

Parameter t (Double)

For plugin version 0.6.0007

149

http://g.shaper3d.cn

IOnLine with IOnLine

Parameters a & b (on first and second line as Double)

RhUtil(Rhino )

Rhino

150

For plugin version 0.6.0007

http://g.shaper3d.cn

For plugin version 0.6.0007

151

http://g.shaper3d.cn

RhUtil Divide curve


RhUtil

RhUtil.RhinoDivideCurve

RhinoDivideCurve:
Curve:
Num:
Len:
False: TRUE FALSE
True: TRUE FALSE
crv_p:
crv_t:

152

For plugin version 0.6.0007

http://g.shaper3d.cn

RhUtil

RhinoInterpCurve:
3:
pt_array:
Nothing:
Nothng:
0:

On3dPoints nurbs

RhUtil Create edge surface RhUtil

For plugin version 0.6.0007

153

http://g.shaper3d.cn

154

For plugin version 0.6.0007

http://g.shaper3d.cn

16 Help

Rhino DotNET SDK


McNeel Wiki

http://en.wiki.mcneel.com/default.aspx/McNeel/Rhino4DotNetPlugIns.html

Forums and discussion groups


Rhino Grasshopper
http://grasshopper.rhino3d.com/
Rhino Developer Newsgroup McNeel

http://www.rhino3d.com/developer.htm
Rhino3d Grasshopper Rhino Grasshopper
Shaper3d http://bbs.shaper3d.cn
Grasshopper http://g.shaper3d.cn

Debugging with Visual Studio Visual Studio


GRASSHOPPER Microsoft
Visual Studio Express
express visual studio
http://en.wiki.mcneel.com/default.aspx/McNeel/DotNetExpressEditions
Visual Studio
http://en.wiki.mcneel.com/default.aspx/McNeel/Rhino4DotNetPlugIns.html

Grasshopper Scripting Samples


Grasshopper

Grasshopper

For plugin version 0.6.0007

155

http://g.shaper3d.cn

Shaper3d Grasshopper Shaper3d Rhino3d


Rhino3d
Rhino3d Rhino3d

Shaper3d
http://bbs.shaper3d.cn
Grasshopper
http://g.shaper3d.cn

/Jessesn

156

For plugin version 0.6.0007

You might also like