Good morning.
I am trying to change the starting point of the list of polycurves that I have, since these vary a lot in their location.
I have made an intersection obtaining points that will be the reference to relocate the starting point of the polycurve… how could I do this operation… thanks to all.
I simply created a python code for you.
It returns regenerated PolyCurves which have startpoints as nearest point to other geometry.(line, point… )
# Load the Python Standard and DesignScript Libraries
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN
def rotate(l,n):#define shift list order
return l[n:]+l[:n]
# Place your code below this line
geo=IN[0]#any geometry(line,point....)
pcurves=IN[1]
new=[]
for pcv in pcurves:
lines=pcv.Explode()
min=1000000000
for i in range(len(lines)):#find start point of each exploded lines
line=lines[i]
p=line.StartPoint
dist=geo.DistanceTo(p)
if dist<min:
ind=i
min=dist
if ind!=0:
lines=rotate(lines,ind)#change order of lines to make the nearest one to the first
pcv=PolyCurve.ByJoinedCurves(lines)#regenerate PolyCurve
new.append(pcv)
# Assign your output to the OUT variable.
OUT = new
4 Likes