Getting Curtain Panel Subcategories and respective Geometry

our office models (in Revit) entire unitized panels, either curtain wall or window wall as curtain panels. If anyone else models this way and has yet to develop a process to inspect the panels and access geometry from the Object Styles (a.k.a. subcategories). ghpython code below, developed with ChatGPT 4o (to be fully transparent)

import clr
clr.AddReference('RevitAPI')
clr.AddReference('RevitAPIUI')
clr.AddReference('RhinoCommon')
clr.AddReference('RhinoInside.Revit')

import Rhino
from Autodesk.Revit.DB import *
from RhinoInside.Revit import Revit, Convert

# Import GeometryDecoder from Convert.Geometry
from RhinoInside.Revit.Convert.Geometry import GeometryDecoder

doc = Revit.ActiveDBDocument

# Ensure E is a list of elements
elements = E if isinstance(E, list) else [E]

# Initialize lists to collect results
all_geometries = []
all_subcategories = []

# Set up geometry options
opts = Options()
opts.ComputeReferences = True
opts.IncludeNonVisibleObjects = True

for element in elements:
    if isinstance(element, Element):
        # Get the geometry of the element
        geom_element = element.get_Geometry(opts)
        if geom_element is None:
            continue
        for geom_obj in geom_element:
            # Handle GeometryInstance (nested geometry)
            if isinstance(geom_obj, GeometryInstance):
                geom_objs = geom_obj.GetInstanceGeometry()
            else:
                geom_objs = [geom_obj]
            for geom in geom_objs:
                try:
                    # Convert Revit geometry to Rhino geometry using GeometryDecoder
                    rhino_geom = GeometryDecoder.ToGeometryBase(geom)
                    if rhino_geom is not None:
                        all_geometries.append(rhino_geom)
                    else:
                        print("Conversion returned None for geometry: {geom}")
                except Exception as e:
                    print("Error converting geometry: {e}")
                    print("Geometry type: {type(geom)}")
                    continue

                # Get the subcategory
                graphics_style_id = geom.GraphicsStyleId
                if graphics_style_id != ElementId.InvalidElementId:
                    graphics_style = doc.GetElement(graphics_style_id)
                    if graphics_style:
                        category = graphics_style.GraphicsStyleCategory
                        if category:
                            all_subcategories.append(category.Name)
                        else:
                            print("Category is None")
                            all_subcategories.append(None)
                    else:
                        print("GraphicsStyle is None for GraphicsStyleId: {graphics_style_id}")
                        all_subcategories.append(None)
                else:
                    print("GraphicsStyleId is InvalidElementId")
                    all_subcategories.append(None)
# Output the results
Geometries = all_geometries      # List of geometry objects
Subcategories = all_subcategories  # Corresponding subcategories