Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
"""Grasshopper Script Instance"""
import sys as sys
import Rhino
import Grasshopper
import rhinoscriptsyntax as rs
import Rhino.Geometry as rg
import random as r
I would like to make some flowers.
#############################################
0. Making a pot
#############################################
plane1 = rs.WorldXYPlane()
circle1 = rs.AddCircle(plane1, 0.2)
plane2 = rs.MovePlane(rs.WorldXYPlane(), [0,0,0.6])
circle2 = rs.AddCircle(plane2, 0.25)
plane3 = plane2
circle3 = rs.AddCircle(plane3, 0.2)
plane4 = rs.MovePlane(rs.WorldXYPlane(), [0,0,0.5])
circle4 = rs.AddCircle(plane4, 0.19)
loft_this = [circle1, circle2, circle3, circle4]
pot = rs.AddLoftSrf(loft_this, start=[0,0,0],
end=[0,0,0.5], loft_type=2)
earth = rs.AddPlanarSrf(circle4)
#############################################
1. Creating the seeds
#############################################
We have to plant seeds inside the pot.
Unfortunately not all seeds will flourish,
if they are planted at too close a distance.
number_of_flowers = 10
seeds = []
for i in range(number_of_flowers):
#############################################
2. Create the positions for the flowerheads
#############################################
Moving them in z-direction...
...and pushing the flowerhead positions outwards.
flower_height = 0.5
flowerheads = seeds
centroid = (rs.SurfaceAreaCentroid(earth)[0][0],
rs.SurfaceAreaCentroid(earth)[0][1],
flower_height)
flowerheads = rs.MoveObjects(flowerheads, [0,0,flower_height])
flowerheads = rs.ScaleObjects(flowerheads, centroid, [3,3,0], False)
#############################################
3. Creating the growth_paths
#############################################
I do this by simply using interpolating curves,....
... which are perfect for this purpose:
Define a starting point and vector and an end point and vector....
.... and you will get a smooth cuve between the points....
.... with the vectors as tangents.
First creating the vetors...
flowerhead_vectors = []
for i,seed in enumerate(seeds):
vector = rs.VectorCreate(seed, flowerheads[i])
flowerhead_vectors.append(vector)
...then the growth_paths.
growth_paths = []
for i,seed in enumerate(seeds):
growth_path = rs.AddInterpCurve(
[seed,flowerheads[i]], degree=3, knotstyle=0,
start_tangent=(0,0,1), end_tangent = flowerhead_vectors[i])
growth_paths.append(growth_path)
Now, for creating the flower straws.
#############################################
4. Creating the flower_operation
#############################################
4.1 Pascals Operation
Pascals Theorem states the following for every ellipse:
If you draw 6 different tangents on the elipse ....
....and take their intersection points...
.... you can create connecting lines between these points.....
.... that will always intersect each other in one point.
Using this theorem allows me to create flowerheads...
....with petals that all converge to one point.
def Pascal_Operation(x,y):
now using this definition of pascals sentence...
... we make some nice flowers.
Its gonna be fun!
4.2 Creating a function for what i like to call "petal_rings"
def petal_ring(x,y, petal_division):
4.3 Creating the flowerheads
def blossom(x,y):
#############################################
5. Bringing it all together
#############################################
blossom_positioned = []
for i in range(number_of_flowers):
#############################################
6. Visualizing it
#############################################
blossoms = blossom_positioned
pot = pot
earth = earth