Using RhinoPolyhedra from Python

I was asked how to create one of the polyhedral shapes, in RhinoPolyhedra, from Python. Here is a simple example:

import clr
import sys
import scriptcontext as sc

sys.path.append("%APPDATA%/McNeel/Rhinoceros/6.0/Plug-ins/Rhino Polyhedra (666ae572-a6c5-44b5-b668-6b503d56c199)/6.0.6844.19198")
clr.AddReference("PolyhedraCommon.dll")

import PolyhedraCommon

polyhedron = PolyhedraCommon.Library.CatalanSolids.DeltoidalHexecontahedron()
polyhedron.Create()
if polyhedron.IsSolid:
    mesh = polyhedron.ToMesh(sc.doc.ModelAbsoluteTolerance)
    sc.doc.Objects.AddMesh(mesh)
else:
    meshes = polyhedron.ToMeshFaces(doc.ModelAbsoluteTolerance)
    for m in meshes:
        sc.doc.Objects.AddMesh(m)

sc.doc.Views.Redraw()

– Dale

2 Likes