Query wall method in complicate case?

Hi there,

Just want to be clear, for a project that has complicated wall built,
i.e. Basic + Curtain(some use basic wall as panel) + Stacked + Component
What is the correct way to query walls?

The goal is to:

  1. Query all of them and count as the way they drew
  2. At the end separate them by system family/kind into different path.

I’ve tried 2 ways to do so as images shown below,
but the result still not as expected.

QUERY WALL FAMILY.rvt (5.4 MB)
QUERY WALL FAMILY.gh (12.2 KB)

There is some overlap in Revit’s methodologies, these Walls are categorized as Curtain Panels, as well as still being Walls.

The stacked wall is a System Family, which has a Type and is a subcategory of Walls.

Hope that helps.