## rhinopython

Studied earlier in Grasshopper here, creating a cycloid-like curve actually mimics the physical process of rotating disks on a path. Below is a test in Rhino Python. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 # Drawing Cycloid-like Curves # 07.08.2017 www.designcoding.net – Tugrul Yazar import rhinoscriptsyntax as rs curv = rs.GetObject("Select curve") qual = rs.GetInteger("Quality",100) radi = rs.GetReal("a radius",4) radi2 = rs.GetReal("Circle radius",4) cua = rs.OffsetCurve(curv,[1,1,0],radi2) cevre = 2 * 3.1415 * radi mimi = [] […]

This Rhino Python script generates the dual of the selected solid object. However it has some bugs and is not working in some cases. This task could be much better solved with meshes because the main problem is to identify the neighbourhoods of faces. Works pretty well with simple objects like boxes. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 # Generating Dual of Selected Polyhedron # 03.08.2017 www.designcoding.net – Tugrul […]

Again, another example of utilizing Rhino Python for educational purposes and especially for designers. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 # Drawing Simple Polygon Fractals # 02.08.2017 www.designcoding.net – Tugrul Yazar import rhinoscriptsyntax as rs centerPoint = rs.GetPoint("Specify the center of polygon") numberEdges = rs.GetInteger("Enter the number of edges", 6, 3) radius = rs.GetReal("Specify the radius of polygon", 10) iterat = rs.GetInteger("Enter the number of iterations", […]

A simple Rhino Python script that generates fractal curves. Example is the test with Gosper-Peano curve. However the script is not supporting segment directions, that is why the result is not the intended curve. Curve directions could be implemented in the future. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 # Drawing Simple Fractal Curves # 31.07.2017 www.designcoding.net – Tugrul Yazar import rhinoscriptsyntax as rs import copy initials = rs.GetObject("Select Initial […]

Studied earlier in Grasshopper here, the sunflower spiral or Phyllotaxis, or Fermat’s spiral could be drawn as an exercise of looping in Rhino Python. 1 2 3 4 5 6 7 8 9 10 # Drawing the Fermat’s Spiral with Circles # 30.07.2017 www.designcoding.net – Tugrul Yazar import rhinoscriptsyntax as rs import math s = 137.508 for n in range(0,500): t = math.sqrt(n) g = n * s z = rs.Polar([0,0,0],g,t) rs.AddCircle(z,0.3)# Drawing the Fermat’s Spiral with Circles # 30.07.2017 www.designcoding.net – Tugrul Yazar import rhinoscriptsyntax as rs import math […]

1 2 3 4 5 6 7 8 9 10 11 12 13 # Drawing the Convex Hull of Given Points # 28.07.2017 www.designcoding.net – Tugrul Yazar import rhinoscriptsyntax as rs points = rs.GetPointCoordinates("Select points") a = min(points) start = a while a: o = a a = points[0] for b in points: if (a[0]-o[0])*(b[1]-o[1])-(a[1]-o[1])*(b[0]-o[0]) < 0: a = b rs.AddLine(o,a) if a == start: break# Drawing the Convex Hull of Given Points # 28.07.2017 www.designcoding.net – Tugrul Yazar import rhinoscriptsyntax as rs points = rs.GetPointCoordinates("Select points") a = min(points) […]

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 # Delaunay Triangulation of Given Points # 27.07.2017 www.designcoding.net – Tugrul Yazar import rhinoscriptsyntax as rs from itertools import combinations as cb points = rs.GetObjects("Select points for Delaunay Triangulation", 1) set = list(cb(points,3)) for tuple in set: c1 = rs.PointCoordinates(tuple[0]) c2 = rs.PointCoordinates(tuple[1]) c3 = rs.PointCoordinates(tuple[2]) if (c1[0]-c2[0])*(c3[1]-c2[1])-(c1[1]-c2[1])*(c3[0]-c2[0]) != 0: circle = rs.AddCircle3Pt(tuple[0],tuple[1],tuple[2]) delaunay = 0 for point in points: if rs.PointInPlanarClosedCurve(point,circle) == 1: delaunay = 1 continue if delaunay == […]

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 # Draw centered hexagonal grid # 25.07.2017 www.designcoding.net – Tugrul Yazar import rhinoscriptsyntax as rs import math hexGridCenter = rs.GetPoint("Specify center point") hexGridExtend = rs.GetInteger("Enter the number of radial levels", 3, 2) hexGridClSize = rs.GetReal("Edge size of hexagons", 1.0) hexGridCAngle = rs.GetReal("Rotation angle of hexagons", 0.0) edges = 6 rs.AddPoint(hexGridCenter) hexGrid = [] pythagoras = 2 * math.sqrt((hexGridClSize * hexGridClSize) – […]