I see that this is an old post but I came across it whilst looking to do a similar thing. The code below got me what I needed, maybe it will still be relevant for you:
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
groups = UnwrapElement(IN[0])
elementlist, curtainWalls = [], []
for item in groups:
memberlist = []
for member in UnwrapElement(item.GetMemberIds()):
#convert ElementId to Element
memberEl = item.Document.GetElement(member)
try:
#filter by elements' Curtain Grid properties
if memberEl.CurtainGrid.NumULines:
memberlist.append(memberEl)
except:
elementlist.append(memberEl)
curtainWalls.append(memberlist)
OUT = curtainWalls, elementlist
Admittedly this is a combination of your code above and the linked forum post https://forum.dynamobim.com/t/how-to-get-curtain-wall-grid-horizontal-and-vertical-grid-count/38374/2?u=eoin_prunty