programming memo 1 (e)

日本語はこちら(去年のポスト)

Python:

print  (command to show text lines of data on console,  for checking changes of numerical data mostly invisible in your code)

“indent”  , “carriage return” are  important for python scripting syntax.

# for comment out. put ‘#‘ at the beginning of line, then that line will be unfunctional.

import (command to import “modules” which extend functions, as  can allow you to use the module in short name which you defined)

import rhinoscriptsyntax as rs
import Rhino.Geometry as rg

for  repeating, possible to code with Lambda functions

Grasshopper  component:

input from left side , output to right side

Grasshopper Python  component:

left side inputs labeled like “x”, “y” can be used in your code as variable named as x, y. you can connect these inputs to slider component as well. You can specify the data type. Inputs can accept list(array of data).

out  mostly connect to panel

a  the port to out rhino preview model, you can direct objects which list

directing objects to a, nested list can not preview nicely, some complex objects like pipe ,
object.append(pipe)
may not work but
object.extend(pipe)
would work.

Rhino – Python:

modules which we use very often
rhinoscriptsyntax for command to rhino
Rhino.Geometry  for data type / structure, basic, basic geometrical data type like Point3d, Vector3d, transforms

—————————————————–

import rhinoscriptsyntax as rs
import Rhino.Geometry as rg
objs = []
posA = rg.Point3d(0,0,0)
vecA = rg.Vector3d(0,10,10)
for i in range(n):
   line = rs.AddLine(posA, posA + vecA)
   posA = posA + vecA
   vecA = rs.VectorRotate(vecA,x,[0,0,1])
   pipe = rs.AddPipe(line,0,1,0,2)
   objs.extend(pipe)
a = objs

Comments are closed.