Remove Empty List Preserving Hierarchy

image
Hi guys I wanna remove the empty lists but want to have my hierachy in the list of list. So basically in this context I want a output list like

  1. Nurbscurve
  2. Nurbscurve
  3. Emptylist

Hope I make myself clear. Help me out. :slight_smile:

Try List.Clean with the boolean set to true:
http://dictionary.dynamobim.com/#/Core/List/Action/Clean
See also:

I can’t find any illustration for List.Clean with boolean set to true. Please send a screenshot if you used it successfully so we can reuse it as a reference for similar issues.

I tried it before… And worked with the levels as well. Doesn’t seem to work

Try playing with the node levels to see if it helps:
http://dynamoprimer.com/en/06_Designing-with-Lists/6-3_lists-of-lists.html
http://dynamobim.org/introducing-listlevel-working-with-lists-made-easier/

Hi Yna, I do understand how levels work. And I have been playing with the levels and Preserving Hierarchy for a few hours already. The issue is with Empty Lists. When I ask any of these nodes to remove the empty lists… they just remove it through n through.
try it out. You will understand what I mean. Have been using Lists and Levels in Lists for quite sometime now.

Sorry I can’t right now. If no one else does, I’ll come back in a few hours on this topic…

Thanks for the support Yna :slight_smile:

Hi @Amrit_Banerjee

Just use “Flatten” node:

Hi Kulkul,
The issue is I won’t have a nurbscurve in every list of lists. Sometimes its all Empty list (when there is no Geometry Intersect in my case).So dynamo entirely remove the Entire Index without a nurbscurve. I want to maintain the index and list it as null or a single empty list when it doesnt find a nurbscurve. Hope that makes it clear. Check the image.

DanEdu.List.Replace should respond to what you describe:


If not, please send a screenshot showing your initial and expected lists :slight_smile:

1 Like

@Amrit_Banerjee Note that Lacing is Longest in the examples below

7 Likes

Hi Yna,
Yes this was what I was doing yesterday as a workaround. But @Vikram_Subbaiah’s Method works like a charm :smiley:

1 Like

Great, you will fine in the Primer more information about lacing if needed:
http://dynamoprimer.com/en/03_Anatomy-of-a-Dynamo-Definition/3-1_dynamo_nodes.html
If you need to preserve the complete structure of the list, you can do it like so:

1 Like

Hi,
I have a similar list problem, but my list only has one level. Is there a way to remove or make Dynamo ignore the “Empty List” values and still preserve the list hierarchy?

What I’m trying to achieve with my script is to check for views placed on sheets and to find views which do not already have the sheet number as a prefix in the view name, and then rename these. The Empty List value shows up for views which already have the sheet number as a prefix and therefor shouldn’t be renamed.

Rename%20Views%20on%20Sheets_not%20already%20renamed

I’ve tried using the List.clean and List.Replace from DanEDU

Any help deeply appreciated!

Until someone who knows how to do this in code blocks comes along, I quickly wrote a python script that should fix it? I am on my way out of the office and didn’t have time to test, but see if it works.

Replaces the SetParameterByName node, same inputs. Python code is:

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)

#The inputs to this node will be stored as a list in the IN variables.
elements = IN[0]
paramName = IN[1]
values = IN[2]

for i in range(len(values)):
	if hasattr(values[i], '__iter__'):
		for j in range(len(values[i])):
			elements[i][j].SetParameterByName(paramName,values[i][j])
	else:
		continue
#Assign your output to the OUT variable.
OUT = elements

Let me know if there are any problems.

3 Likes

Actually I’ve been so busy with other things so I haven’t had time to test the Python suggestion.

If only I could clone myself…

I’ve forgotten to answer you!
I actually ended up rewriting the entire script, turning things around.
Instead of grabbing sheets and looking for the view names for the views on these sheets I’m grabbing views and comparing their view name with their sheet numbers. Much easier!

1 Like

Hi there,

There is a helpful video for who would like to filter empty lists.

YouTube - Dynamo Filter Empty Lists