Duals of Polyhedra with Rhino Python

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 Yazar
import rhinoscriptsyntax as rs
solid = rs.GetObject("Select object")
result = rs.ExplodePolysurfaces(solid)
points = []
for surf in result:
	temp = rs.DuplicateSurfaceBorder(surf)
	points.extend(rs.PolylineVertices(temp))
unique = rs.CullDuplicatePoints(points)
for pp in unique:
	rs.AddPoint(pp)
	newface = []
	for surf in result:
		if rs.IsPointOnSurface(surf,pp):
			tempa = rs.SurfaceAreaCentroid(surf)
			newface.append(tempa[0])
	newface = rs.SortPointList(newface)
	if len(newface) == 3 or len(newface) == 4:
		rs.AddSrfPt(newface)
	else:
		newface.append(newface[0])
		temps = rs.AddPolyline(newface)
		rs.AddPlanarSrf(temps)
rs.DeleteObjects(result)
rs.DeleteObject(solid)
rs.DeleteObjects(temp)
«
»