Scripting a truncated cone with Python

Maybe I’m just blind, but I can’t find a method for creating a truncated cone like this:

image

The AddCone method always creates a cone to a point, and I’m sure it’s easy enough to chop that point off at a given height, but I thought I’d ask the forum if there is a more elegant way of handling truncated cones.

Thanks,

Dan

import Rhino.Geometry as rg

def AddTruncatedCone(plane, height, base_radius, top_radius):
    bottom_circle = rg.Circle(plane.Origin, base_radius)
    top_circle = rg.Circle(plane.Origin + plane.ZAxis * height, top_radius)
    shapeCurve = rg.LineCurve(bottom_circle.PointAt(0), top_circle.PointAt(0))
    axis = rg.Line(bottom_circle.Center, top_circle.Center)
    revsrf = rg.RevSurface.Create(shapeCurve, axis)
    tcone_brep = rg.Brep.CreateFromRevSurface(revsrf, True, True)
    return tcone_brep

a = AddTruncatedCone(Plane, Height, BaseRad, TopRad)

TruncatedCone.gh (7.0 KB)

https://developer.rhino3d.com/samples/rhinocommon/add-truncated-cone/

2 Likes

Thanks. This should be helpful.

Dan