I am trying to change nodes by code, but I had some problems, hope you can help me.
I have a list of lines in dir x, others in dir y, and the outer curves of surfaces.
Some lines of dirx and dir y are repeated with the exterior ones, what I am looking for is to evaluate their distance with a midpoint of the internal lines with the exterior and any line that has the distance 0, is removed from the list, in order to have a list with no repeating elements.
I have tried to implement this code test but it does not work for me, at the moment it is giving me an error, which is most likely because the method changes in PythonScript vs DesignScript.
It would be of great help if you could give me your support, thank you very much in advance.
ExCs = List.Flatten(ExtCurves)
XCs = List.Flatten(XCurves)
YCs = List.Flatten(YCurves)
#nx= List.UniqueItems(List.Flatten([ExCs,XCs,YCs]))
Clean Curves
for exc in ExCs:
ptex = Curve.PointAtParameter(exc)
for xc in XCs:
ptex = Curve.PointAtParameter(xc)
dx = Geometry.DistanceTo(ptex,ptex)
if ptex == 0:
continue
nx.append(xc)
I think you need to change to be an else, or remove the indention from the append so it happens if not 0, or it will always continue and not give value.
Thank you very much for your response, but does not work
nx=[]
for exc in ExCs:
ptex = Curve.PointAtParameter(exc)
for xc in XCs:
ptx = Curve.PointAtParameter(xc)
dx = Geometry.DistanceTo(ptex,ptx)
if dx == 0:
continue
else:
nx.append(xc)
Because even does not eliminate the lines that are in the same place, additionally create an overlap lines because the evaluation, do you have any other option?
this code get the StartPoint (not the midpoint), because there is no parameter argument (0 to 1) ptex = Curve.PointAtParameter(exc)
Python is an object-oriented language, you can directly use object methods rather than systematically calling the Class
so to get a midpoint of a curve, this ptex = Curve.PointAtParameter(exc, 0.5)
can be replaced by ptex = exc.PointAtParameter( 0.5)
I check for one item and it works like you show in your screen but if I want to use for a list, how I need to do it, because if I create a nested for to iterate a list its appear that the method intersect does not exist, what I am doing wrong, can you explaining, and thank you very much for your time.
def isOverlap(Line1,Line2):
for l1 in Line1:
for l2 in Line2:
LineInt = Line1.Intersect(Line2)
Evlines= any([isinstance(x,Line) for x in LineInt])
# if not Evlines:
return LineInt
OUT = isOverlap(IN[0],IN[1])
Thank you very much for your petition, I changed the code but it still does not have the result that I look, I created a simplify example so you can help me to understand how I need to code this problem.
Sorry Kulkul if I do not explain well in the first statement and in the script, The result that I want to achieve is from the exterior list, remove all the elements that are overlapping with X and Y, in this case is only one to simplify the problem.
So I want the unique lines from the lists that I input, for those that are overlapping I want to remove or drop from one list, to have the lists clean.