Working Planes

1. Review of conditions statements

import rhinoscriptsyntax as rs
a=list()
for i in range(20):
    if i%4==0:
        a.append(rs.AddCircle((i,0,0),1))
    else:
        plane=rs.PlaneFromFrame((i,0,0),(1,0,0),(0,1,0))
        a.append(rs.AddRectangle(plane,1,1))

1.png

"i%4" is the modulo of i with 4. (Modulo is a remainder of i divided by 4)

2. Planes

We have several ways to create planes.

import rhinoscriptsyntax as rs
a=list()
a.append(rs.PlaneFromPoints((0,0,0),(1,0,0),(0,1,0)))
a.append(rs.PlaneFromFrame((0,10,0),(1,0,0),(0,1,0)))
a.append(rs.PlaneFromNormal((0,0,10),(0,0,1),(1,0,0)))

2.png

3. PlaneFromPoints

3.png
import rhinoscriptsyntax as rs
 
a=rs.PlaneFromPoints(O,X,Y)

4.png

4. PlaneFromFrame

5.png
import rhinoscriptsyntax as rs
a=rs.PlaneFromFrame(O,vX,vY)

6.png

5. PlaneFromNormal

7.png
import rhinoscriptsyntax as rs
a=rs.PlaneFromNormal(O,vN,vX)

8.png

6. Working Planes

Let's start with this.

import rhinoscriptsyntax as rs
points=list()
points.append((6,1,0))
points.append((11,0,0))
points.append((11,6,0))
points.append((6,6,0))
a=rs.AddPolyline(points)

9.png
import rhinoscriptsyntax as rs
plane=rs.WorldXYPlane()
points=list()
points.append(rs.EvaluatePlane(plane,(6,1)))
points.append(rs.EvaluatePlane(plane,(11,0)))
points.append(rs.EvaluatePlane(plane,(11,6)))
points.append(rs.EvaluatePlane(plane,(6,6)))
a=rs.AddPolyline(points)

You will get the same result as the previous one.
9.png

Comment out "plane=rs.WorldXYPlane()" and add an input parameter with name "plane".
Connect all the planes to "plane".
You may get
10.png

7.

11.png
import rhinoscriptsyntax as rs
 
points=rs.PolylineVertices(pL)
N=len(points)-1
a=list()
for i in range(N):
    O=(points[i]+points[i+1])/2   #Point+Point=Point
    vY=points[i+1]-points[i]      #Point-Point=Vector
    vX=rs.VectorCrossProduct(vY,(0,0,1))
    plane=rs.PlaneFromFrame(O,vX,vY)
    a.append(rs.AddRectangle(plane,1,5))

12.png
13.png
import rhinoscriptsyntax as rs
 
points=rs.PolylineVertices(pL)
N=len(points)-1
a=list()
for i in range(N):
    O=(points[i]+points[i+1])/2   #Point+Point=Point
    vY=points[i+1]-points[i]      #Point-Point=Vector
    vX=rs.VectorCrossProduct(vY,(0,0,1))
    plane=rs.PlaneFromFrame(O,vX,vY)
    ps=list()
    ps.append(rs.EvaluatePlane(plane,(-0.5,-2.5)))
    ps.append(rs.EvaluatePlane(plane,(0.5,-2.5)))
    ps.append(rs.EvaluatePlane(plane,(0.5,2.5)))
    ps.append(rs.EvaluatePlane(plane,(-0.5,2.5)))
    ps.append(rs.EvaluatePlane(plane,(-0.5,-2.5)))
    a.append(rs.AddPolyline(ps))

14.png