This is Exercise One: Python Batch Program. For this exercise, we were asked to write a working batch program that generates a very simple drawing, such as a pattern of tiles, a type of window, a section of a pillar, a bathroom, etc, making use of the functions we have learned during the first three classes.
Here is the Python Code:
import rhinoscriptsyntax as rs import math as m #four points: 0,0 3,-y 6,0 3,y #angle: 30degrees rad=deg*pai/180 #y=3*tan30=1.73205 rs.DeleteObjects (rs.AllObjects()) #Assign coordinates to an object obj = rs.AddPolyline (([0,0,0],[3,-1.73205,0],[6,0,0],[3,1.73205,0],[0,0,0])) #Give coordinates of center point, and rotate point = [0,0,0] rs.RotateObject (obj, point, -60, None, copy=True) point = [6,0,0] rs.RotateObject (obj, point, 60, None, copy=True) rs.SelectObjects(rs.AllObjects()) #Array intx = rs.GetInteger ("Please insert number of diamonds", 18) rs.Command ("arrayLinear " + str(intx) + " 0,0 6,0") rs.SelectObjects(rs.AllObjects()) #angle: 30degrees #Long=6, x=Long*sin30=3, y=Long*cos30=5.19615 intx = rs.GetInteger ("Please insert number of diamonds", 27) rs.Command ("arrayLinear " + str(intx) + " 0,0 3,-5.19615") Aobj = rs.AllObjects() #rs.Command ("arrayPolar 0,0 6 360 Enter") for i in range (1,6): angle = 360/6 rs.RotateObjects (Aobj, [0,0,0], angle*i, None, True)