Join Lines with extend line

Join Points with extend line
33333

Are you looking to merge the lines into one line, or connect the two as a polycurve to account for lines which are not aligned?

I want to add lines between lines (The problem that connect to closest point but I want to add angle… So that it is along the lines or closer to the extension, but does not connect perpendicular to the line
2222

Get the points of the lines, sort them clockwise by their point coordinates x and y and create a polycurve then explode the geometry and sort curves by length? Then get the first and the second of the list which are longest as the result

How can I use clockwise?
And is there a way to extend lines to meet the other line?

You didn’t ask to extend lines you are asking to add lines to fill the gap. I don’t know if is possible to extend lines, what are the lines in Revit?

Hello, there must certainly be faster but it should work

Cordially
christian.stan

1 Like

Lines from cad

If I have more than 4 points
I want to be a general .
11111111

Hello, you will have to adapt in this case
1st trick 2 points 2nd trick 4 points

Cordially
christian.stan

We need a dataset to help; post the DWG witht he condition(s) your’e working with.

Mostly they seem to work with a PolycCurve.ByJoinedCurves, and a PolyCurve.CloseWithLine node.

Test1.dwg (1.6 MB)

PolyCurve.CloseWithLine is good but when this case
44444444

It’s likely there is a better way to solve the larger problem this is a part of, but this Python will take a PolyCurve and join it to an adjacent PolyCurve by drawing the line from the end point of the first Polycurve to the closest point at parameter 0 or 1 of the second PolyCurve. It also has an optional boolean input to close the entire curve as needed, and will work with a series of PolyCurveas well.

Careful selection of the curves to make PolyCurve, or use of the GroupCurves node (from Archi-Lab) or your own method thereof should make this workable.

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import PolyCurve, Geometry, Curve, Line

inCrvs = IN[0] #the curves from the Dynamo environment
closePoly = IN[1] #boolean indicated if the polycurve should be closed
joinedCurve = PolyCurve.ByJoinedCurves([inCrvs.pop()]) #take one curve out of the inCrvs list and convert it to a PolyCurve

while inCrvs: #while there are items in the inCrvs list
    endPnt = Curve.PointAtParameter(joinedCurve,1) #get the end point of the 
    dists = [Geometry.DistanceTo(endPnt,i) for i in inCrvs] #get the distance from the end of the initial curve to each curve still in the inCrvs list
    next = [x for y,x in sorted(zip(dists,inCrvs))][0] #gest the next curve from the in crvs list based on the shorted distance to the end point
    nextPnts = [ Curve.PointAtParameter(next,i) for i in [0,1] ] #get the start and end point from the next curve
    pntDists = [Geometry.DistanceTo(endPnt,i) for i in nextPnts] #get the distance from the end point of the init curve to the start and end point of the next cruve 
    nextPnt = [x for y,x in sorted(zip(pntDists,nextPnts))][0] #get the cloest of the next curves end points to the init curves endpoint
    newLine = Line.ByBestFitThroughPoints([endPnt,nextPnt]) #build a line from the closest end point of teh next curve to teh end point of the init curve
    joinedCurve = PolyCurve.ByJoinedCurves([joinedCurve,newLine,next]) #build a new polycurve from the init curve, next curve, and new line
    inCrvs.remove(next) #remove the next curve from the list of inCrvs

if closePoly: joinedCurve = PolyCurve.CloseWithLine(joinedCurve)

OUT = joinedCurve #returns the joined polycuve to the Dynamo environment
4 Likes

You can use this node from “BriMohareb_2023”

1 Like

@jacob.small I tried to apply the code repeatedly, but it always gets an error, and I don’t know the cause of the problem

I can’t reproduce - post your DYN where you implemented it, along with a dataset to do so (ie: a Revit file with the necessary objects in it to just run the Dynamo graph).

Column.dwg (1.5 MB)