Hey guys, I’m basically trying to loft some curves and just cannot figure out why my lofts wont come out clean. I got my lofts, but they are like twisted or something, almost as if its skipping the mid curve. The curve in the middle is usually smaller than the first two curves which is why I used length to identify it.
import rhinoscriptsyntax as rs
from Rhino.Geometry import *
import System.Drawing.Color as color
import Rhino
import time
import math
import sys
sys.path.append("C:\\BMIRhinoTools\\Source")
import MO
import System.Drawing.Bitmap as BM
import utility as rhutil
def preloft(curves):
plane = rs.WorldZXPlane()
bbox2 = rs.BoundingBox(curves)
cur_cen = (bbox2[0]+bbox2[6])*0.5
a = rs.AddPoint(cur_cen)
b = rs.VectorCreate([0,0,20],[0,0,0])
c = rs.VectorCreate([20,0,0],[0,0,0])
d = rs.VectorCreate([-20,0,0],[0,0,0])
point1 = rs.CopyObject(a,b)
point2 = rs.CopyObject(a,c)
point3 = rs.CopyObject(a,d)
boundary = rs.AddCircle3Pt(point1,point2,point3)
return (boundary)
inputc = rs.ObjectsByLayer("NewNostrils",rs.filter.curve)
bound = preloft(inputc)
surface = rs.AddPlanarSrf(bound)
rs.DeleteObject(bound)
right_nostril =[]
left_nostril =[]
for i in inputc:
bbox = rs.BoundingBox(i)
cent = (bbox[0]+bbox[6])*0.5
if cent.X>0:
left_nostril.append(i)
else:
right_nostril.append(i)
#gettherightcurves
lower_right_curve = rs.PointClosestObject([0,0,-10],right_nostril)[0]
lower_left_curve = rs.PointClosestObject([0,0,-10],left_nostril)[0]
top_right_curve = rs.PointClosestObject([0,0,20],right_nostril)[0]
top_left_curve = rs.PointClosestObject([0,0,20],left_nostril)[0]
#getthecurvelenght
lowleft_len = rs.CurveLength(lower_left_curve)
topleft_len = rs.CurveLength(top_left_curve)
lowright_len = rs.CurveLength(lower_right_curve)
topright_len = rs.CurveLength(top_right_curve)
#getthemiddlecurves
mid_left_curve =[]
mid_right_curve =[]
for cur_a in left_nostril:
if rs.CurveLength(cur_a) < lowleft_len and rs.CurveLength(cur_a) < topleft_len:
mid_left_curve.append(cur_a)
for cur_b in right_nostril:
if rs.CurveLength(cur_b) < lowright_len and rs.CurveLength(cur_b) < topright_len:
mid_right_curve.append(cur_b)
#Startlofting
for cur in inputc:
int = rs.CurveSurfaceIntersection(cur,surface)
param = int[0][6]
rs.CurveSeam(cur,param)
if(not rs.CurveDirectionsMatch(cur,inputc[0])):
rs.ReverseCurve(cur)
#LoftCurves
rs.DeleteObject(surface)
rightLoft = rs.AddLoftSrf((top_right_curve,mid_right_curve[0],lower_right_curve),None,None,1,1,155)[0]
lefttLoft = rs.AddLoftSrf((top_left_curve,mid_left_curve[0],lower_left_curve),None,None,1,1,155)[0]