Get parameter associated with nested family parameter

Trying to find a method for this but am not having much luck.

I’m trying to determine what parameters in a nested family are controlled by the parent and what parameters in the parent are associated with the nested parameter.

Basically, I want to tab select a nested shared family, run the command and have it check every parameter in the nested family to see if it is controlled by the parent and then copy that value to a selected element.

I know how to navigate supercomonents and subcomponents so I don’t think that will be an issue, I just don’t know how to check and get the controlling parameter in the parent. I tired GetAssociatedGlobalParameter on the off chance that a nested family would treat parameters in the parent as global but it returned -1 so no luck.

Code needs to be cleaned up a bit. Just testing stuff right now.

# Import libraries
from pyrevit import revit, forms, script, EXEC_PARAMS
from Autodesk.Revit.DB import (Transaction, Connector)
from Autodesk.Revit.UI import (UIApplication)
from Autodesk.Revit.DB.Plumbing import Pipe

# Current document
doc = __revit__.ActiveUIDocument.Document
cView = doc.ActiveView
uiapp = UIApplication(__revit__.Application)
uiDoc = __revit__.ActiveUIDocument
from rpw.ui.selection import Pick, Selection


# ################################################################################
# Debug toggles
globalDebug = True
disabledScript = False


def dprint(*printItems):
    if globalDebug:
        for pI in printItems:
            print(pI)



########################################################################################################################
# Selection
selection = revit.get_selection()
element = selection[0]
########################################

dprint(selection)
dprint(element.Name)

elem_param = element.GetOrderedParameters()
dprint(elem_param)
for ep in elem_param:
    dprint(ep.Definition.Name)
    dprint(ep.GetAssociatedGlobalParameter())