PolyCurve.ByJoinedCurve - Not Working in Python Node

Hi All,

I am trying to join curves which are coming out of the Room.CoreBoundary in a python node. When I do it as a code block it works fine but once I write similar code in a python node it gives me the following error:

Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 14, in
TypeError: Error in IEnumeratorOfTWrapper.Current. Could not cast: Autodesk.DesignScript.Geometry.Curve in IronPython.Runtime.List

I’m assuming there is something simple that I am missing here. If anyone can point me in the right direction I would really appreciate it.

*Disclaimer, I need this to work within the python script as this is only a portion of my true goal. The remaining more extensive code has been cut out as

I have identified this as what is creating the issues here.

Use a tuple instead of a list
…ByJoinedCurves(tuple(lines))

Hi Thomas,

Thanks for that quick response. I tried that but unfortunately that didn’t change anything.

Looks like a rank issue then, just index your lines variable:
…ByJoinedCurves(lines[0])

3 Likes

Thank you Thomas! That indeed did work. Could I ask just so that I may understand for future reference how did you understand that from the error code?

The Curve[ ][ ] is in reference to the output data structure, in this case the double square brackets means a 2D array (aka a list of lists). The same is true for inputs.

Hence, in your for loop, your lines variable is a 2D array but Curve.ByJoinedCurves() requires a 1D array. If you index the lines it will get the first sub-list in the array which satisfies the input for ByJoinedCurves(). The first sublist from a room boundary array is always its outermost profile - any other sublist will be an interior boundary created by a column or any other room bounding element within the room. Hence, if you never have such conditions or if its unimportant, you can safely get the first index this array - like what I’ve done - and that’s the maximum extents of your room.

So going back to your question then…just a bit of guess work as the exception is telling - although a bit cryptically - that there is a problem with your list and now you know its the data structure that is triggering the problem.

I really appreciate that extremely detailed and thorough explanation. Thank you for taking the time to help me!

Hi,
I have a problem that seems very similar to me but I could be wrong.
I am trying to make a plaster finish of rooms in apartments using a script. I insert the room and run the script:

by area there should be 4 curves but the script reads 6:


the script creates 3 collinear trim elements after the run is complete.
The question is, is there any possibility to combine them into one element or for the script to read one curvature instead of 3?

Any idea? :slight_smile: