I’m trying to get the Group Names of all the Text in my document.
The snippet I have show below works fine as long as the FIRST element found is Grouped, but if the first element is NOT Grouped, the whole thing fails.
Any idea for a work-around? I can’t really sort my list. What I’ve posted is just a snip from a larger program that needs to preserve the original order.
First image shows results if the first element is in a Group
Second image shows the failure when the first element is not in a Group
Split the list of groups into nulls and groups before you try to get the names. Filter by bool mask with isnull as filter should work.
Then how do I put the two lists back together again in the same order that they were originally?
Can you try this python script?
OUT = []
for e in IN[0]:
if e == None:
OUT.append("Ungrouped")
else:
OUT.append(e.Name)
Doubtless your Python node would be more efficient, but I have figured out a method using only OOTB nodes.
This might not be optimal performance, but it works.
It doesn’t keep my original List order, but I can do this early enough in the process so that I can use the “new” order.
Thanks for your help.