Hello and thanks for your answer.
I am sorry for the horrible question, hope this is a better representation of it:
The Image function does not work, so I am unable to visually represent what I have so far. (The points and lines in 3D space)
The code so far gets input a list of lines, which create a few grids of lines, and the code finds the lines intersectionspoints to create a pointgrid.
I cannot wrap my head around how to find the centerpoints of each grid (see picture).
The
Dynamo is a visual programming software used for modeling, which has an implemented IronPython node.
Do you have any clue?
Here is the code:
I am sorry for the horrible question, hope this is a better representation of it:
The Image function does not work, so I am unable to visually represent what I have so far. (The points and lines in 3D space)
The code so far gets input a list of lines, which create a few grids of lines, and the code finds the lines intersectionspoints to create a pointgrid.
I cannot wrap my head around how to find the centerpoints of each grid (see picture).
The
dataEnteringNode = INand the
OUTare needed for the "Node" to read information into the pythonscript, and output the result back into the Dynamo program.
Dynamo is a visual programming software used for modeling, which has an implemented IronPython node.
Do you have any clue?
Here is the code:
import clr clr.AddReference('ProtoGeometry') clr.AddReference('DSCoreNodes') import DSCore from DSCore import * from Autodesk.DesignScript.Geometry import * #The inputs to this node will be stored as a list in the IN variables. dataEnteringNode = IN OUT = [] def line_intersects(p1sp,p1ep,p2sp,p2ep): xdiff = (p1sp.X - p1ep.X, p2sp.X - p2ep.X) ydiff = (p1sp.Y - p1ep.Y, p2sp.Y - p2ep.Y) def det(a1,a2,b1,b2): return a1 * b2 - a2 * b1 div = det(xdiff[0],xdiff[1],ydiff[0],ydiff[1]) if div <> 0: d = (det(p1sp.X,p1sp.Y,p1ep.X,p1ep.Y), det(p2sp.X,p2sp.Y,p2ep.X,p2ep.Y)) x = det(d[0],d[1], xdiff[0],xdiff[1]) / div y = det(d[0],d[1], ydiff[0],ydiff[1]) / div if x > p1sp.X and x < p1ep.X and y > p2sp.Y and y < p2ep.Y: return Point.ByCoordinates(x,y) for l1 in IN[0]: p1sp = l1.StartPoint p1ep = l1.EndPoint data = [] for l2 in IN[0]: if l1 <> l2: p2sp = l2.StartPoint p2ep = l2.EndPoint if p1sp.X < p2sp.X and p1ep.X > p2ep.X or p1sp.Y > p2sp.Y and p1ep.Y < p2ep.Y: if not (line_intersects(p1sp,p1ep,p2sp,p2ep) is None): data.append(line_intersects(p1sp,p1ep,p2sp,p2ep)) if data.Count > 0: OUT.append([l1,data])