Thanks for the links.
List of sorted curves?
Sorted how?
Sorted by intersection.
First all LineEndPoint Intersection and second all lines with intersection between LineEndPoints.
The goal is to calculate all weigth points for a booth rig like Dancergraham mentioned in this post Result forces on a grid.
This represents the rig above the booth where all light instalations are fixed.
This is the code to get the curve order (thats what i try to make in c#)
import Rhino as rh
C = [] # Sorted rig
# Order to calculate
def calculation_order(x):
if len(x) >= 0:
for j in x:
L = []
for e in x:
if e != j:
CrvEnd = rh.Geometry.CurveEnd.Both
ej = rh.Geometry.Curve.Trim(j,CrvEnd,2)
#E.append(ej)
L.append(rh.Geometry.Curve.ClosestPoint(ej,e.PointAtStart,1)[0])
L.append(rh.Geometry.Curve.ClosestPoint(ej,e.PointAtEnd,1)[0])
if any(L) == False:
C.append(j)
x.remove(j)
return calculation_order(x)
calculation_order(x)
And this is the code to calculate the weight for all endpoints.
Only the endpoints with a higher count than 1 are calculatet.
import Rhino as rh
L = []
D = {}
for i in C:
SP,EP = i.PointAtStart,i.PointAtEnd
L.append(SP)
L.append(EP)
D[SP] = []
D[EP] = []
J = []
for i in range(0,len(C)):
# create Start and Endpoint weights for all rig parts
SP,EP = C[i].PointAtStart,C[i].PointAtEnd
weight = (rh.Geometry.Curve.GetLength(C[i])*z)/2
D[SP].append(weight)
D[EP].append(weight)
for j in D:
if rh.Geometry.Curve.GetLength(C[i]) > rh.Geometry.Curve.ClosestPoint(C[i],j,1)[1] > 0:
print i
SP_factor = rh.Geometry.Point3d.DistanceTo(SP,j)/rh.Geometry.Curve.GetLength(C[i])
EP_factor = 1 - SP_factor
SP_weight = sum(D.get(j))*EP_factor
EP_weight = sum(D.get(j))*SP_factor
D[SP].append(SP_weight)
D[EP].append(EP_weight)
sum(D.get(SP))
sum(D.get(EP))
J.append(j)
D1 = {}
SL = (set(L))-(set(J))
for i in SL:
if i in D:
D1[i] = sum(D[i])
Dv = D1.values()
Dk = D1.keys()
I try to make this in c# just for learning purpose and to make fast loading compiled tools for grasshopper