The methods presented below can be used to generate data objects in list format from given input parameters.
Series of numbers (Series)
The component SeriesInputs Start (S) First number in the series Step (N) Step size for each successive number Count (C) Number of values in the series Outputs Series (S) Series of numbers
Series of characters (Char Sequence)
The component Char SequenceInputs Count (C) Number of elements in the sequence. Char Pool (P) Pool of characters available to the sequence. Format (F) Optional formatting mask Outputs Sequence (S) Sequence of character tags Axis {0}
will become Axis A, Axis B, etc. Once all
available characters are used up, they will be concatenated: X, Y, Z, AA, AB,
AC, ….
Subdivide number range (Range)
The component RangeInputs Domain (D) Domain of numeric range Steps (N) Number of steps Outputs Range (R) Range of numbers
Generate random numbers (Random)
The component RandomInputs Range (R) Domain of random numeric range Number (N) Number of random values Seed (S) Seed of random engine Outputs Random (R) Random numbers
By default, the generated numbers will have 6 decimal places. We can right-click the component and select the option Integer Number to only receive integers.
Duplicates elements in a list (Duplicate Data)
The component Duplicate DataInputs Data (D) Data to duplicate Number (N) Number of duplicates Order (O) Retain list order Outputs Data (D) Duplicated data
At input O (Retain list order) we can influence the duplication procedure. If
we switch from True to False
, the list is no longer appended en bloc, but
every element is duplicated n-times and before continuing with the next element.
Repeat items in a list (Repeat Data)
The component Repeat DataInputs Data (D) Pattern to repeat Length (L) Length of final pattern Outputs Data (D) Repeated data
The items at input D will be repeated, if the requested length exceeds the
number of provided items. If we provide the alphabet as input data, then after
Z will follow A. This way, we achieve a different behavior compared to how
Char SequenceInputs Count (C) Number of elements in the sequence. Char Pool (P) Pool of characters available to the sequence. Format (F) Optional formatting mask Outputs Sequence (S) Sequence of character tags
Multiply specific items in a list (Stack Data)
The component Stack DataInputs Data (D) Data to stack Stack (S) Stacking pattern Outputs Data (D) Stacked data
Generate a sequence of numbers (Sequence)
The component SequenceInputs Notation (N) Sequence notation Length (L) Final length of sequence Initial (I) Initial values in sequence Outputs Sequence (S) Sequence
To illustrate the example shown in the image above, we use the notation [N-1] + [N-2]
together with two initial values (here 0
and 1
). The first two values
of our generated list are determined by the initial values and thus are 0 and
1. The third value is calculated by adding the last value N-1 and the value
before last [N-2]. Continuing, this gives:
0: 0 initial value
1: 1 initial value
2: 1 (1 + 0)
3: 2 (1 + 1)
4: 3 (2 + 1)
5: 5 (3 + 2)
6: 8 (5 + 3)
7: 13 (8 + 5)
This sequence is better know as Fibbonacci
sequence and Grasshopper offers
a dedicated component to calculate this special sequence: FibonacciInputs Seed A (A) First seed number of the sequence Seed B (B) Second seed number of the sequence Number (N) Number of values in the sequence Outputs Series (S) First N numbers in this Fibonacci sequence
Besides simple mathematical operators, we can also provide more complex expressionsInputs Notation (N) Sequence notation Length (L) Final length of sequence Initial (I) Initial values in sequence Outputs Sequence (S) Sequence [N-1] + If([N-1]%2=0,1,9)
will add the value of 1 to every even number and
9 to every uneven.