Python Practice #00 | review


  1. Function
    1. Task
    2. Pipeline
  2. Data Tree
    1. Task
    2. Pipeline
  3. Rhino Command
    1. Task
    2. Pipeline



スクリーンショット 2015-01-29 15.03.45 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


  • 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


#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


スクリーンショット 2015-01-29 16.21.57 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


  • 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


#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


スクリーンショット 2015-01-29 15.36.31 make a component to unroll object

  • use <obj> <active> as input data


  • 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


#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