Retrieve level and level Id of the active view plan (Python)

Hi everyone,
I’m trying to retrieve a bunch of properties and parameters of an active plan view, and for some reason, the Python script keeps returning a null result for the associated level LookupParameter.
I’ve also tried the GenLevel method with similar results.

Even more peculiar, is that it does seem to work for plans, filter-collected as a class.

Here’s the relevant code,

Thanks for the help!

Ok, problem seems to be solved.
I’m not sure why or how, but the active view in Revit might not have been a plan.

The view may have been the project browser, judging by the ElementId

1 Like

Allright, it really explains why the script was sometimes working and other times it didn’t.
I didn’t know the browser was a view.