Loft in rhinoscriptsyntax

I’m trying to make a script that lofts 2 closed curves. One in an “irregular circle” (it’s a circle when looking from the top plane, but the 3d geometry is irregular) and the other one is just a bigger concentric circle.

I’m trying to do it with just rhinoscriptsyntax.

The loft works great when done manually but when I try doing with a script I end up with the monstrosity below:

What I’ve already tried:

  • Using points to guide the loft
  • Changing the curve directions to match
  • Using the sweep2 instead of a loft (couldn’t even get that to work)
    None of the above worked for me.

Here’s the code:
tryingToLoft.py (721 Bytes)

import rhinoscriptsyntax as rs

baseCurves = rs.SelectedObjects()
for curve in baseCurves:
if rs.IsCircle(curve):
smoothCircle = curve
else:
perimeter = curve

sameDirection = rs.CurveDirectionsMatch(perimeter, smoothCircle)
if not sameDirection:
smoothCircle = rs.ReverseCurve(smoothCircle)

closestPoints = rs.CurveClosestObject(perimeter, smoothCircle)
sweepLine = rs.AddLine(closestPoints[1], closestPoints[2])
rs.AddLoftSrf([perimeter, smoothCircle], closestPoints[1], closestPoints[2], 3, 1, 100)

#rs.AddLoftSrf([perimeter, smoothCircle]), None, None, 3, 1, 100)
#rs.AddSweep2([perimeter, smoothCircle], sweepLine, True)

I’m also attaching the file with the 2 curves if anyone wants to give it a try. You need to select the curves first before running the script.
2 closed curves.3dm (94.9 KB)

Any help is appreciated

hi @robneto.eng see if this helps (no error checking):

import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino
from Rhino.Geometry import *

curves = rs.SelectedObjects()
crvs = [rs.coercecurve(c) for c in curves]

start = crvs[0].PointAtStart
_, cp = crvs[1].ClosestPoint(start)
pt = crvs[1].PointAt(cp)
crvs[1].ChangeClosedCurveSeam(cp)

loft = Brep.CreateFromLoftRebuild(crvs, Point3d.Unset, Point3d.Unset, LoftType.Normal, False, 100)[0]
sc.doc.Objects.AddBrep(loft)
1 Like

It does work, thanks!

But I can see you’re using rhino.geometry to create the loft. Any idea why it doesn’t work with rhinoscriptsyntax?

The only way to make this work is to modify one of the curve’s seam

Just tried that and got same results. Now I’m wondering if rhinoscriptsyntax loft is just bugging out.