More python 3 that's not working

Code based on the archilab node Revision Properties:
I’m trying to get issue information; sequence, date, issued etc.

In IronPython it all works.

In py3 I can only seem to get the sequence. I’ve checked the API and the methods don’t seem to have changed… What’s happening?

def ProcessList(_func, _list):
    def apply_func(x):
        if isinstance(x, list):
            return ProcessList(_func, x)
        else:
            # if no a list
            return _func(x)
    return map(apply_func, _list)


def UnwrapNestedList(issues):
	return UnwrapElement(issues)
def GetSequence(issues):
	return issues.SequenceNumber
def GetDate(issues):
	return issues.RevisionDate


if isinstance(IN[0], list):
	revs = ProcessList(UnwrapNestedList, IN[0])
else:
	revs = [UnwrapElement(IN[0])]

try:
	sequence = ProcessList(GetSequence, revs)
	date = ProcessList(GetDate, revs)
except:
	import traceback
	OUT = traceback.format_exc()


OUT = sequence, date

And the output is information in the sequence list but blank lists for date (and any other parameter I tried)

It might be helpful if you show the full code and the working version in IronPython. It feels like there’s a lot of unnecessary code here and it makes troubleshooting a little more difficult than it should be.

The methods definitely still work. As you said, they haven’t changed, and the Revit side would be unaffected by the Python changes anyway. If you’re running into issues, then it’s with how you’re handling the Revit data in a Pythonic way. Simplify your code to the basics parts and then try rebuilding it. As I mentioned, there seems to be a bunch of unnecessary code that may be causing some confusion.

1 Like

If you try returning each property list individually it works. It always works for the first list and returns empty for the following lists. The issue here is that your list processing functions are doing exactly that: they’re processing a given list and returning a modified version of that list, not a new one. So when you process revs to get the sequences, you’re saying sequence is now the modified version of the original revs list, not a duplicate. Same thing happens when you get the dates.

In my opinion, the best solution would be to just handle the list management within your property loops to keep things less confusing. However, you can also get around this pretty easily by just using the python input (IN[0]) for each property loop instead of reusing the revs list. This will require you to handle the element unwrapping at the input variable declaration, but that’s the best place to do it in my opinion anyway.

Python Example
def ProcessList(_func, _list):
    def apply_func(x):
        if isinstance(x, list):
            return ProcessList(_func, x)
        else:
            # if no a list
            return _func(x)
    return map(apply_func, _list)

def UnwrapNestedList(issues):
    return UnwrapElement(issues)
def GetSequence(issues):
    return issues.SequenceNumber
def GetDate(issues):
    return issues.RevisionDate

input = UnwrapElement(IN[0])

if isinstance(input, list):
    revs = ProcessList(UnwrapNestedList, input)
    print("UnwrapNestedList: List")
else:
    revs = [UnwrapElement(input)]
    print("UnwrapNestedList: List")

try:
    sequence = ProcessList(GetSequence, input)
    date = ProcessList(GetDate, input)
except:
    import traceback
    OUT = traceback.format_exc()

OUT = revs, sequence, date