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.
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?
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).
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.
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
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:
Increase (make the number smaller) the joining tolerance of the Polycurve.ByJoinedCurves().
Eliminate the very small curves from the list and play with the Joining tolerance.
@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.
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 !
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)
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)