I would love to follow up on this forum post. I am trying to do something very similar, but I am also wanting to take into account two sets of areas for each drainage area. I have soil type and then also land use type. I think I have it down to the end where I have the surface representing the land uses within each drainage area being compared to the overall soil type map.Then I try to get the surface area and then get the sum of each at the end, but when I try to do thsi Math.sum node, it gives me null values whenever there is a surface nested within the list? Screenshot attached.
It would be helpful to know what each of those list levels represents (you have a lot, some likely unnecessary) and whether any can be flattened.
The issue you have right now, as specified by the error, is rank reduction. Essentially, your list structure isn’t correct for the input structure (lacing) you’ve specified based on the node requirements. In effect, you’re asking the node to sometimes act on a list and sometimes on a single value or list of different structure (in some cases, a structure that doesn’t actually exist). You need to keep an eye on where your empty lists are occurring. You can only sum a list of values, so you have to target a list structure. List levels makes this way easier than lacing. Your list of area values is at Level 2 (@L2) so you would set values@L2. This will give you a total area for lists with values and a sum of 0 for lists without values. The first problem is that you also have empty lists at Level 3 (@L3). This means that you have some condition where you don’t even get to the point of checking areas (and why we need to know what all these levels represent).
The rank reduction issue is essentially the inverse of the problem above. If you have the node sum values @L3 you’d be asking the node to add up lists instead of numbers. You’re asking it to treat a structure like an object, which isn’t possible in this case.
What you are showing makes sense to me. I am not sure how to make this work for my situation, so I will try and provide more context.
I have 3 .dwg’s with areas designated. Polylines create drainage boundaries (current file), then I have XREF’d in a Land Use.dwg with hatched areas for different land use types, then I have another .dwg XREF’d in that shows hatches areas for 4 different soil types.
From here, I am creating surfaces for each drainage area, each land use type, and each soil type. Land use hatches and soil type hatches can create multiple surfaces. From here, I do use the Geometry.Intersect node to compare the Drainage area surfaces with the Land use type surfaces. Screenshot below:
*Note: Blue Group is the drainage area surfaces (here only 4)
Green Group is creating the Impervious Area surfaces
Then I take this output of new surfaces (which I believe should be individual surfaces within each drainage area for this particular land type, and then compare it a specific soil type to return any areas that it contains there. Screenshot below:
*Note: Green Group is the previous Geometry.Intersect from the last screenshot
Orange creates the surfaces for Soil Type A, in this case
Purple Now compares the surfaces from the Drainage area vs Land use analysis to compare that to the soil type.
Ultimate end goal of this is to get data compiled like this and exported to excel, for each drainage area:
It’s really hard to help when we can’t see any of the node outputs to know what you’re dealing with. I still suspect you have too many list levels for what you’re trying to accomplish - there is likely a way to simplify this. An alternative would be to use python so that you know which lists to dig into and sum and which are empty and can be avoided (return 0 if necessary).
I have been trying to get a python script to work for me today and I am really struggling to get it to work. ChatGPT says I need to run it in IronPython and not CPython3?
Chat got is lying… in your original screenshot which level do you want the sums to be taken? The node can only work at one level, so you may need to standardize the structure to start off.
It’s definitely doable in python with some assumptions. Again, you’re better off determining where you can simplify your structure and how you want to handle non-existent situations (where you have empty lists of empty lists). You can sum an empty list, but you can’t sum a list that doesn’t exist.