Hi!
Been asking a bunch of questions lately, thanks for being patient with me
I can’t show the entire code here, and it wouldn’t serve the purpose anyway, but I have a curve that I rebuilt before
select_edge = disc_edges[i]
select_reb = rg.PolylineCurve.Rebuild(select_edge, 2, 0, True)
if not cut_crv:
cut_crv.append(select_reb)
That curve stays the same during the iterations of the loop, and at a later part of the definition that curve is referenced, it should rotate once and have both versions (rotated and original) test against another curve - then select the needed curve and extend it:
''' Cutting Line '''
cut_lines=[]
cut_pt_dis=[]
pt_i = random.randint(0, len(div_pt) - 1)
selected_pt = div_pt[pt_i]
line_ext = copy.deepcopy(cut_crv[0])
line_ext_r = copy.deepcopy(line_ext)
rotate = rg.Transform.Rotation(math.radians(90), mid_pt)
line_ext_r.Transform(rotate)
vec = rg.Line(mid_pt, selected_pt)
vec_dir = vec.Direction
move = rg.Transform.Translation(vec_dir)
line_ext.Transform(move)
cut_lines.append(line_ext)
line_ext_r.Transform(move)
cut_lines.append(line_ext_r)
for crv_test in cut_lines:
ctpt = crv_test.PointAt(0.6)
clt = rg.Curve.ClosestPoint(cut_crv[0], ctpt)
clpt = rg.Curve.PointAt(cut_crv[0], clt[1])
dispt = rg.Point3d.DistanceTo(ctpt, clpt)
cut_pt_dis.append(dispt)
sorted_cut_lines = [x for y, x in sorted(zip(cut_pt_dis, cut_lines))]
select_cut_line = sorted_cut_lines[1]
extended_line = select_cut_line.Extend(999, 999)
Now it all works, until I extend it after selecting the right one. Simply either nothing happens, or only one of the sides of the curve extends, doesn’t seem like there’s a logic error in the code (correct me if I’m wrong), seems more of a bug than anything else.
The original curve is highlighted and as you can see, it only extends one side:
Any ideas?
Edit: If I do a PointAt on both ends (0, 1) and build a Line, then transform this line into a NurbsCurve, then extend it - it works perfectly. But it’s such a stupid workaround to do every single time… Maybe it’s a problem with data types or some common thing with curves in Rhino?
Thanks a bunch,
Lev