Python Practice #00 | review
Contents
- Function
- Task
- Pipeline
- Data Tree
- Task
- Pipeline
- Rhino Command
- Task
- Pipeline
Function
Task
make a component to orient object in circular array
- use <obj> <radius> <count> as input data
- make a function that orient object with polar coordinates
Pipeline
- import
- import rhinoscriptsyntax
- import math
- function (orient object with polar coordinates)
- calculate x,y from theta and radius
- return x,y as Point3d
- main process
- copy object to move
- calculate theta from counter
- get x,y as Point3d with function
- move copied object with Point3D
Hints
#import rhinoscriptsyntax #import math #define function named "polarCoordinates" with two arguments angle and radius #calculate theta in radians from degrees #calculate x with theta and radius #calculate y with theta and radius #make point at x,y #return point #declare list named objs #loop from i=0 to count #define angle in degrees #copy object to move #get target point to move by using function above #move object to move with target point #add moved object to objs #substitute objs to a
Data Tree
Task
make a component to orient multiple objects in 3D matrix
- arrange objects in DataTree
- use <objs>(obejcts to move) <x>(x bound) <y>(y bound) <z>(z bounds) <step>(distance between each cells) as input data
Pipeline
- import
- import rhinoscriptsyntax
- import clr and add “Grasshopper” to references
- import GH_Path and DataTree
- main process
- copy objects to move
- make moving Point3d
- make path with loop index (i,j,k)
- append copied objects to datatree with path
Hints
#import rhinoscriptsyntax #import clr #add "Grasshopper" to reference of clr #import GH_Path #import DataTree #import System #declare tree as datatree #loop from i=0 to x #loop from j=0 to y #loop from k=0 to z #make copy of objects to move #make Point3d for moving #move copied objects with Point3d #make path with i,j,k #add objects to tree #substitute tree to a
Rhino Command
Task
make a component to unroll object
- use <obj> <active> as input data
Pipeline
- import
- import rhinoscriptsyntax
- import Rhino
- import scriptcontext
- main process
- get object ID
- get geometry and attributes from object ID
- go to Rhino workspace
- bake object to Rhino workspace
- select object
- unroll object with Rhino Command
- go back to grasshopper
Hints
#import rhinoscriptintax #import Rhino #import scriptcontext #check active or not if yes then run the code bellow #go to grasshopper work space #get real object from object ID in grasshopper #get attributes from real object #get geometry from real object #go to rhino work space #bake object with geometry and attributes #select baked objects #unroll it #delete it #back to grasshopper work space