nd sort by the y_valuessorted_pts_y = [pt for (y, pt) in sorted(zip(y_values, points))]
# get the x-values from your now freshly sorted points listx_values = [pt[0] for pt in sorted_pts_y]
# zip the sorted_points_y and x_values lists together and sort by the x-valuessorted_pts_xy = [pt for (x, pt) in sorted(zip(x_values, sorted_pts_y))]
## Script end ##If your not familiar with Python list comprehensions, simply google them to find out more about it.
Basically, this:
y_values = [pt[1] for pt in points]
Is the same as this:
y_values = [] for pt in points: y_values.append(pt[1])Furthermore, this part:
sorted_pts_y = [pt for (y, pt) in sorted(zip(y_values, points))]Is the same as this:
sorted_pts_y = [] for (y, pt) in sorted(zip(y_values, points)): sorted_pts_y.append(pt)…
he start point.
Generation (2) i have 4 points + (3*3points) = 13 points.
Generation (3) i have 13 points + (9*3points) = 50 points.
But when i bake the python component i have 157 points ? Why ?
What's the logic behind this ?
Also how can i have in a, lists of points according to generations and for exemple in b lines according to generations too ??
Here's the code:
import rhinoscriptsyntax as rsimport random as rr.seed(seed)
def Main():....allGenerations = []....allGenerations.append(startPt)....curGeneration = []....curGeneration.append(startPt)....for i in range(gens):........newGeneration = []........for pt in curGeneration:............ang1 = r.randint(-30,30) ............ang2 = r.randint(90,150) ............ang3 = r.randint(210,270) ............dist1 = r.randint(10,40) ............dist2 = r.randint(10,40) ............dist3 = r.randint(10,40) ............zV = -1 ............newPoints = branch(pt, ang1, ang2, ang3, dist1/(i+1), dist2/(i+1), dist3/(i+1), zV) ............newGeneration.extend(newPoints) ............curGeneration = newGeneration ............allGenerations.extend(newGeneration)....return allGenerations
def branch(pt, ang1, ang2, ang3, dist1, dist2, dist3, zV):....ptP1 = rs.Polar(pt, ang1, dist1)....ptP2 = rs.Polar(pt, ang2, dist2) ....ptP3 = rs.Polar(pt, ang3, dist3) ....ptA1 = rs.AddPoint(ptP1)....ptA2 = rs.AddPoint(ptP2)....ptA3 = rs.AddPoint(ptP3) ....pt1 = rs.MoveObject(ptA1, [0,0,zV])....pt2 = rs.MoveObject(ptA2, [0,0,zV])....pt3 = rs.MoveObject(ptA3, [0,0,zV]) ....ln1 = rs.AddLine(pt, pt1)....ln2 = rs.AddLine(pt, pt2)....ln3 = rs.AddLine(pt, pt3) ....return [pt1, pt2, pt3]
a = Main()
Thanks for you replies and sorry for my noob questions...
…
ts the "0th" points of every path. How would i connect, say, 1 st pt on the 1st curve w/ 2nd pt on the 2nd curve; 3rd pt of 2nd curve w/ 4th pt on 3rd curve ... so on. i'm trying to create the connecting line separately, rather than 1 continuous line.
thx…
t case point 3 should be able to move from 20 to 33
so in other word
pt 3 depends on pt 2
the problem is if i only have sliders
pt2 could be 20
and pt 3 could be 20, that is higher than 33
so the loft loops in itself
gracias por tu ayuda
salu2
m…
Curve)
Dim spanVec(0) As Double
inCrv.GetSpanVector(spanVec)
Dim arrPt As New List (Of On3dPoint)
For i As Int32 = 0 To spanVec.Length() - 1
Dim pt As New On3dPoint
pt = inCrv.PointAt(spanVec(i))
arrPt.Add(pt)
Next
A = arrPt
End Sub…
t is nearly straight. smaller must be a kink (corner). Deepending on you geometry you might have to change the 3 rad to get the result you want.
Best regards
DeDackel…
Added by Dedackelzucht at 8:16am on October 10, 2011