I don’t understand how to correctly draw a U-channel using Python

I’ve supplied the Python component with all the required dimensions to build the channel’s section curve. I know how to construct the curve with sharp corners, but I need to fillet the inner corners with one radius and a couple of the outer corners with a different radius. It’s the filleting that’s causing the problem.



This is what I ended up with

And this is what I need to get
Cluster_channel.ghcluster (3.4 KB)

Instead of using the method to fillet all corners with the same radius you may want to look into CreateFilletCurves, handling each corner pair with the correct radius.

From my testing, CreateFilletCurves sometimes fails, so I would suggest explicitly calculating the offsets and creating the required arcs and then joining everything.

Also, you’re script appears to make no use of the s input parameter, so there might be a logic error somewhere.

I’ve modified your script to use explicit arcs rather than fillets as well as omitting the hw and hb parameters since those values can be inferred from the other parameters.

import Rhino.Geometry as rg
import scriptcontext as sc
import ghpythonlib as gh
from ghpythonlib.components import Fillet

assert len(parameters) == 6, "Wrong number of parameters"

# U-channel
h, b, s, t, r1, r2 = [p * unit_scale for p in parameters]

pts = [
    rg.Point3d(     0,           0, 0), #  0
    rg.Point3d(     0,          -h, 0), #  1
    rg.Point3d(     b,          -h, 0), #  2
    rg.Point3d(     b, -h + t - r2, 0), #  3
    rg.Point3d(     b,      -h + t, 0), #  4
    rg.Point3d(b - r2,      -h + t, 0), #  5
    rg.Point3d(s + r1,      -h + t, 0), #  6
    rg.Point3d(     s,      -h + t, 0), #  7
    rg.Point3d(     s, -h + t + r1, 0), #  8
    rg.Point3d(     s,     -t - r1, 0), #  9
    rg.Point3d(     s,          -t, 0), # 10
    rg.Point3d(s + r1,          -t, 0), # 11
    rg.Point3d(b - r2,          -t, 0), # 12
    rg.Point3d(     b,          -t, 0), # 13
    rg.Point3d(     b,     -t + r2, 0), # 14
    rg.Point3d(     b,           0, 0), # 15
]

polycurve = rg.PolyCurve()
polycurve.Append(rg.Line(pts[0], pts[1]))
polycurve.Append(rg.Line(pts[1], pts[2]))
polycurve.Append(rg.Line(pts[2], pts[3]))
polycurve.Append(rg.Arc(pts[3], pts[4]-pts[3], pts[5]))
polycurve.Append(rg.Line(pts[5], pts[6]))
polycurve.Append(rg.Arc(pts[6], pts[7]-pts[6], pts[8]))
polycurve.Append(rg.Line(pts[8], pts[9]))
polycurve.Append(rg.Arc(pts[9], pts[10]-pts[9], pts[11]))
polycurve.Append(rg.Line(pts[11], pts[12]))
polycurve.Append(rg.Arc(pts[12], pts[13]-pts[12], pts[14]))
polycurve.Append(rg.Line(pts[14], pts[15]))
polycurve.Append(rg.Line(pts[15], pts[0]))

tol = sc.doc.ModelAbsoluteTolerance
polycurve.MakeClosed(tol)

geometry = polycurve.ToNurbsCurve()

Thank you so much! You’ve been incredibly helpful. I spent a long time trying to figure out how to complete this task but couldn’t find a solution (I’m a beginner), and now I finally understand how this kind of thing should be done