Polycurves and adaptative component

Hi Everyone,

I try to attribute adaptative model element from points with dynamo. In my case I have 3D polycurves on autocad 3D (polycurves composed of arcs and lines). Each polycurves has different length and are composed of different number of arcs and lines. I have successful to do it to attribute a 3 point adaptative component for each portion of polycurve. However, I want to have 1 element for each curve (and no 1 element for each portion of polycurve) and 1 family type must be used (I have created a family type with 50 adaptative points).

Thus, I need 50 points for each autocad polycurve, how can I get that easily ?

Also, how it’s possible to obtain a 2D list with the distinction of polilyne ? For example bellow the node give me a list of all portions of all polycurves but I want a real 2D list who the two polycurves are differentiated.


Thank you in advance for your proposals !

Hi,

I don’t get what you exacly try to do here.

It looks like you want to join the curves segments you get from Autocad. To join the segments you get from the node CAD.CurvesFromCADLayers, you can try Polycurve.ByJoinedCurves. This will turn a List of joined curves into 1 Polycurve.

And do you want to place an adaptive component family with 50 points along these curves? Like some kind of sweep?

1 Like

Hi,

Firstly, thanks for your answer @Joelmick . I tried to use the node « Polycurve.ByJoinedCurves » but it didn’t work because I have more than one polycurve. I want to have a 2D list and for each polycurve, the list oh these component (curve, arc…) in order to get point coordinates. For exemple, if I have 3 Autocad 3D polycurve :

Then I could get 50 points and apply my adaptive component and I’ll get 1 REVIT element for each polycurve and not 1 element for ach component of the polycurve (that is what I get actually).

I explain you what I want in the end, maybe it will be easier to understand. The target is to generate post-tensionning (PT) cable with a generic adaptative model. I get the profile of these cables by autocad 3D polycurves. I want to get 50 points of each Autocad 3D polycurve and put my adaptative family. I want to have 1 REVIT element for each polycurve (1 PT profile = 1 REVIT element).

Have you an idea ?

If its still unclear I can try to explain again

1 Like

Aha thanks for the explaination.

I don’t know why the PolyCurve.ByJoinedCurves fails, what kind of error do you get?

Below I attached a example on how to can tackle your problem for the Post Tension cables.

The only risk with this methode is that you always require 50 points in a Family, and this might be enough for this case but for the next case the accuracy of 50 points is not enough and you need 60 for example. Then you have to create a whole new family with 60 Adapative points.

But anyway, let me know if this works for you
JoinCurvesAndDivide.dyn (42.7 KB)

1 Like

Thanks for this @Joelmick, in my case, I have choosen 50 points because for my project it’s suffcient. But yes I’m agree with you this method has disadvantages.

However I still have the problem with Polycurve.ByJoinedCurves node.

The error is : Warning: PolyCurve.ByJoinedCurves operation failed. Curve join produced more than one WIRE in PolyCurve

I can’t get the 2D list. I don’t understand why, maybe it’s a problem with CAD.CurvesFrmCADLayers node ?

Have you an idea ?

hmmm okay, this error most likely means that the Polycurve in Autocad contains some very small curves. The Polycurve.ByJoinedCurves doens’t know which curves to join sinces the very small curves are within the joining tolerance. So you can do 2 things:

  1. Increase (make the number smaller) the joining tolerance of the Polycurve.ByJoinedCurves().

  2. Eliminate the very small curves from the list and play with the Joining tolerance.

1 Like

@Joelmick I think the problem is different. He don’t know hw many Autocad polycurve there is, then for Dynamo there isonly one polycurve and he d’oesn’t successful to join cruves. I must obtain a 2D list like I show in my precedent post. In this way, PolyCurve.ByJoindeCurves may know how many polycurve he have to create and with which components.

Have you an Idea ?

Thanks

Coming back to the Issue with the 2D List, I think you already have it.

In fixing that Polycurve Issue, can you try the methodes below?


FixingThePolyCurve.dyn (29.9 KB)

If you can share your project + graph we can help you better by trying stuff.

1 Like

Thanks

I tried what you describe above, it didn’t work. I maintain my opinion, I know that I have a 2D list but within it, my polycurves are not bundled and I think that is the problem. I think because of that the Node PolyCurve.ByJoinedCurves don’t know how many polycurve there are.
I share you my files :

  • Dynamo file with your 3 solutions and another solution. I tried to bundled polycurve with the node Group Curve (archilab package), it works, I’ve successful to get polycurve BUT when I have a lots of polycurves in my autocad, it crash and I don’t know why. Then, with this method I haven’t be able to get 50 point (with the way that you explain yesterday).
  • Revit and dwg file

Thank you a lot for your previous answers, if you have any other ideas I’m listenning !

200505_Dynamo forum.dyn (44.2 KB) Test_Précontrainte_2polylignes.rvt (808 KB) 2Polyligne_3D.dwg (43.7 KB)

Aaah okay my bad, now that I have the files I see you get a 1D List with all the curves on the same layer from the CAD.CurvesFromCADLayers. The GroupCurves is indeed a good fix for small files. I have tested this for alot of curves and indeed it crashes as well.

In this case the best thing you can do is to help you algorithm with more info. Give the cables different layers in Autocad so you can import them by layer in Dynamo so they are already in a list together. I would also make it easier to mark them later (So you can see which cable came from which Autocad Curve)

1 Like

Thank you very much for yours responses !

SortPolyCurves.dyn (26.7 KB)

Hi, I was bothered that the Archilab algorithm took so long so I rewrote it and made is a bit faster.

This algorithm groups the curves and creates polycurves out of them. This should fix the problem.

Cheers

2 Likes

Hi @Joelmick this is really awesome. It works great ! Thanks, I’ll try to underfstand your python script in order to upgrade my python level.

Thank you very much !

1 Like

Hi, please could you modify the code to work with list of lists?

I will post the python code for a list of curves. It is easy to make it work for a list of list with curves. Please try it yourself and if you do not figure it out, please let me know.

# Load the Python Standard and DesignScript Libraries
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

clr.AddReference("System")
from System import String
from System.Diagnostics import Stopwatch

# The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN

def GroupCurves(curves, ignoreDistance = 0.1):
    polycurves = []
    
    startcurve = curves[0]
    del curves[0]
    
    while len(curves)>0:
        group = [startcurve]
        startP = startcurve.StartPoint
        endP = startcurve.EndPoint
        for curve in curves:
            startFound = False
            endFound = False
            ind = curves.IndexOf(curve)
            
            if startP.DistanceTo(curve.StartPoint) <= ignoreDistance:
                curve.Reverse()
                group.append(curve)
                del curves[ind]
                startFound = True
                break
            
            elif startP.DistanceTo(curve.EndPoint) <= ignoreDistance:
                group.append(curve)
                del curves[ind]
                startFound = True
                break
            
            elif endP.DistanceTo(curve.StartPoint) <= ignoreDistance:
                group.append(curve)
                del curves[ind]
                endFound = True
                break
                
            elif endP.DistanceTo(curve.EndPoint) <= ignoreDistance:
                curve.Reverse()
                group.append(curve)
                del curves[ind]
                endFound = True
                break
            
        if len(group) > 1:
            startcurve = PolyCurve.ByJoinedCurves(group)
            
        else:
            #Add the Polycurve to the output list
            polycurves.append(startcurve)
            
            #Assign a new Start curve
            startcurve = curves[0]
            
            #Delete the Start curve from the Bucket
            del curves[0]
            group = [startcurve]
            
    #Add the Last Curves
    polycurves.append(PolyCurve.ByJoinedCurves(group))
    return polycurves


# Place your code below this line
curves = IN[0]


# Assign your output to the OUT variable.
OUT = GroupCurves(curves)
1 Like