I wonder if you can help me. I have stumbled on finding a way to organize the points coming from “Curve.IntersectAll” from Bimorph package.
I am trying to allow the user to sketch a number of lines in any sequence. Then grab the intersecting point from the lines and finally draw a closed polygon.
You can see in the attached image the weird polygon shape…!
Perhaps draw the convex hull of the collection of points, pull each point to the hull, find the parameter of each point on the hull, and use that to sort the points?
@Vikram_Subbaiah Thanks a lot, the related post is very helpful… I am getting close to to this , especially it works, no errors and it creates non-intersecting closed curves.
But the resulting closed curve is not what it is supposed to be…
My goal of this project is to find the correct boundary so I can calculate the closed curve area from these random interesting lines.
Sorry for he trouble… I am beginner in this new project.
Out of curiosity, why are you approaching it this way? Would it be easier to get the closest intersecting curve to each starting curve instead? What is the larger workflow for?
Hello @jacob.small … well, may be I am not approaching correct! Or there could be a better method as you suggested.
The big picture is that these random lines represent column grids created a project which had been placed at different sequence in the project. I am simply trying to obtain the intersecting points between the lines, so I can calculate the closed curve area from these random intersecting lines.
I wonder if you have a resource or sample to the “closest intersecting curve” method.
Hmmm… can you share the lines as you currently have them? Have a few ideas with this larger goal in mind, but they may not pan out.
I’m not using my work CPU today (holiday), so no Revit or Dynamo playtime on stuff like this for at least 24 hours, but someone else might be able to help out and provide an idea once you post those files.
Thanks @jacob.small … and I appreciate you all looking and helping me with this. I totally understand and here are attached the Revit + Dynamo Graph attempts.
I have modified the graph. One good thing is: 1) It looks like I can grab “All other Line segments” with their Start/End point of each segment as a result of “Geometry.DoesIntersect” method. But How can I can I create a line from each sub-list? 2) There is also the last closing segment unique start and end point shown in the list. Which is great, but how can I grab them as unique two items to draw a closing line segment.
What is the outcome of the final List.Map node? Might be better to use a Line.ByBestFitThrougjPoints (or even a Curve.SplitByPoints node then taking the even segments) and then use a Polycurve.ByJoinedCurves node to join them into one.
Hi @jacob.small … here is the outcome of the final List.Map. I am just unable/stuck to filter the last segment line that contains the start/end points.
Hello
a solution with Python should be work in most case
import sys
import clr
import itertools
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
def customIntersectAll(*args):
for curveA, curveB in itertools.product(*args):
interSet = curveA.Intersect(curveB)
for i in interSet:
if isinstance(i, Point) and 0.02 < curveA.ParameterAtPoint(i) < 0.98:
yield(i)
def sortPoint(lstPts, orderPts = []):
global lstCurveA
if len(orderPts) == 0:
orderPts.append(lstPts.pop(0))
#
lstPts.sort(key = lambda x : x.DistanceTo(orderPts[-1]))
for idx, pta in enumerate(lstPts):
lineAB = Line.ByStartPointEndPoint(pta, orderPts[-1])
if any(len(lineAB.Intersect(x)) > 0 and isinstance(lineAB.Intersect(x)[0], Line) for x in lstCurveA):
orderPts.append(lstPts.pop(idx))
return sortPoint(lstPts, orderPts)
return orderPts
lstCurveA = IN[0]
lstCurveB = lstCurveA[:]
outPoint = []
for pt in customIntersectAll( lstCurveA, lstCurveB):
if all(not pt.IsAlmostEqualTo(x) for x in outPoint):
outPoint.append(pt)
OUT = sortPoint(outPoint)
Thank you all @c.poupin@jacob.small@Vikram_Subbaiah for helping me with this… really appreciate it.
I am not familiar with Python and the code block… it is way on top of my head and need to understand these different parts of code.
I want to try it and let you know.
Thanks a lot.