Minimum radius on curve?

I’ve searched the forums, but the Curvature command still seems to involve a bit of manual guesswork. Is there a command I’ve missed which can tell me the minimum radius of the entire curve?

The curve was projected onto a mesh and then rebuilt within a tolerance.

section.3dm (2.5 MB)

Hi @eobet ,
There you go with a script that does what you need

import rhinoscriptsyntax as rs
import Rhino
import scriptcontext
import System.Guid
import math

def GetMinimumRadius():

    curves = rs.GetObjects("Select curves to analyze", 4, preselect=True)
    if not curves: return
    
    min_radius = float('inf')
    min_radius_point = None
    min_radius_curve_id = None
    
    for curve_id in curves:

        curve = rs.coercecurve(curve_id)
        if not curve: continue

        domain = curve.Domain

        samples = 1000  #should be adapted to curve lngh
        parameters = [domain.ParameterAt(t / float(samples - 1)) for t in range(samples)]
        
        for t in parameters:

            vector = curve.CurvatureAt(t)
            if vector:
                curvature = vector.Length
                if curvature > 0:  
                    radius = 1.0 / curvature
                    if radius < min_radius:
                        min_radius = radius
                        min_radius_point = curve.PointAt(t)
                        min_radius_curve_id = curve_id
    
    if min_radius == float('inf'):
        print("No curvature found - curves may be linear")
        return

    if min_radius_point:

        point_id = rs.AddPoint(min_radius_point)
        rs.ObjectColor(point_id, (255, 0, 0))  
        

        circle = rs.AddCircle(min_radius_point, min_radius)
        rs.ObjectColor(circle, (0, 255, 0)) 
        
        text = "Min Radius: {:.3f}".format(min_radius)
        rs.AddTextDot(text, min_radius_point)
        
        rs.SelectObject(min_radius_curve_id)
    
    print("Minimum radius of curvature: {:.3f}".format(min_radius))
    return min_radius


if __name__ == "__main__":
    GetMinimumRadius()

It should solve your issue,
Should you need anything just dm me
Hope this helps
Farouk

1 Like

Wow, thank you so much! :partying_face: :trophy:

In Rhino 7 it works very well (one small nitpick is that the circle should not be centered on the point but that’s details), however in Rhino 8, I honestly don’t know how to get it to run:

image

Using either Run commands under these confusingly named options, I get various errors…

Can anyone from McNeel clarify why this has been made more convoluted instead of easier?

did you try the ExtractMinMaxRadiusPoints command?

@eobet “EditPythonScript” is the command you’re looking for.
Anyway I love Rhino8, having python3 pip packages is a really solid feature, I don’t think It’s a downgrade.
Btw you should be able to make a custom button with the script running I’m quite sure How to add custom button with Py.script in Rhino interface
Farouk