The issue is that if you want to loft (for example) a polygon and a circle together, python has problems aligning the start points of the curves which can lead to unexpected results(see Fig.1).

import rhinoscriptsyntax as rs

import math

import random

hex = rs.GetObject()

circ = rs.GetObject()

loftL = [hex,circ]

loft = rs.AddLoftSrf(loftL)

So what I did is wrote a function that will align the seams of the curves and then loft them together so that a python loft will match a rhino loft(Fig.2)

import rhinoscriptsyntax as rs

import math

import random

def loft(_crvList):

crvList = _crvList

for i in range (0,len(crvList)-1):

rs.CurveSeam(crvList[i+1],rs.CurveClosestPoint(crvList[i+1],rs.CurveStartPoint(crvList[0])))

srf = rs.AddLoftSrf(crvList)

return srf

crvs = rs.GetObjects('select curves',4)

loft(crvs)

Very easy little function(only 6 lines of code) that will save a lot of headache if you have problems with your lofts. It can be copied and pasted into any script and just use that instead of the rs.AddLoftSrf command and it will work no matter how many curves you are trying to loft together

Well done Dennis!

ReplyDeleteThe other option would be to approximate the upper circle with many segment and connect them with mesh to the lower shape (it happens anyway when you export to print it)