Duct Connector parameter help

I am needing help with retrieving duct connector associated parameters.

The script below was my attempt in trying to at least find the possible parameters that could be used for the built-in Height, Width, Radius/Diameter parameters for the connectors.

I took a look using the RevitLookup tool and was able to drill down to

MEPModel>ConnectorManager>ConnectorSet but the most i got out of it was Shape, Radius, not the associated created parameter.

Not sure if anyone has done anything with duct/pipe connectors before. Hoping someone has dealt with connectors and can provide some insight.

The family i used was the out of the box Autodesk round damper family for testing.

# -*- coding: utf-8 -*-
__title__ = "Test Duct Connector"


import clr

clr.AddReference("RevitAPI")
clr.AddReference("RevitAPIUI")

from Autodesk.Revit.DB import *
from Autodesk.Revit.UI.Selection import ObjectType, ISelectionFilter

from pyrevit import revit, script, forms


doc = revit.doc
uidoc = revit.uidoc
output = script.get_output()


# ------------------------------------------------------------
# Selection Filter
# ------------------------------------------------------------
class DuctAccessoryFilter(ISelectionFilter):

    def AllowElement(self, elem):
        try:
            if elem.Category.Id.IntegerValue == int(BuiltInCategory.OST_DuctAccessory):
                return True
        except:
            pass
        return False

    def AllowReference(self, reference, position):
        return False


# ------------------------------------------------------------
# Pick Accessory
# ------------------------------------------------------------
try:

    ref = uidoc.Selection.PickObject(
        ObjectType.Element,
        DuctAccessoryFilter(),
        "Select a duct accessory"
    )

except:
    forms.alert("Selection cancelled.", exitscript=True)


accessory = doc.GetElement(ref.ElementId)

output.print_md("## Accessory Selected")
output.print_md(accessory.Name)


# ------------------------------------------------------------
# Helper Filter
# ------------------------------------------------------------
def is_candidate_parameter(p):

    try:

        if p.StorageType != StorageType.Double:
            return False

        if p.IsReadOnly:
            return False

        if not p.CanBeAssociatedWithGlobalParameters():
            return False

        return True

    except:
        return False


# ------------------------------------------------------------
# Collect Parameters
# ------------------------------------------------------------
candidates = []

for p in accessory.Parameters:

    if not is_candidate_parameter(p):
        continue

    try:
        name = p.Definition.Name
        val = p.AsDouble()

        val_in = val * 12.0

        label = name + "  (" + str(round(val_in,3)) + " in)"

        candidates.append((label, p))

        output.print_md(label)

    except:
        pass


typ = doc.GetElement(accessory.GetTypeId())

for p in typ.Parameters:

    if not is_candidate_parameter(p):
        continue

    try:
        name = p.Definition.Name
        val = p.AsDouble()

        val_in = val * 12.0

        label = name + "  (" + str(round(val_in,3)) + " in) [TYPE]"

        candidates.append((label, p))

        output.print_md(label)

    except:
        pass


if not candidates:
    forms.alert("No candidate parameters found.", exitscript=True)


# ------------------------------------------------------------
# Choose Parameter
# ------------------------------------------------------------
labels = [c[0] for c in candidates]

chosen_label = forms.SelectFromList.show(
    labels,
    title="Select Parameter To Modify",
    multiselect=False
)

if not chosen_label:
    forms.alert("No parameter selected.", exitscript=True)


chosen_param = None

for label, param in candidates:
    if label == chosen_label:
        chosen_param = param
        break


# ------------------------------------------------------------
# Ask for New Size (Inches)
# ------------------------------------------------------------
new_size = forms.ask_for_string(
    prompt="Enter new size (inches)",
    title="Modify Parameter"
)

if not new_size:
    forms.alert("No value entered.", exitscript=True)


try:
    new_size_in = float(new_size)
except:
    forms.alert("Invalid number.", exitscript=True)


new_size_ft = new_size_in / 12.0


# ------------------------------------------------------------
# Apply Change
# ------------------------------------------------------------
t = Transaction(doc, "Modify Size Parameter")
t.Start()

try:

    chosen_param.Set(new_size_ft)

    doc.Regenerate()

    output.print_md("Parameter Updated")

except:

    output.print_md("Failed to set parameter")

t.Commit()

@Rafael-Marquez

Parameter you are pointing out “Duct Radius” is not connector parameter. This is normal parameter added to family. To get this, you need to use LookupParameter functionality.

your_element_instance.LookupParameter(“Duct Radius”).AsDouble()

So i don’t have an issue looking up the parameter. The issue is retrieving duct connector associated parameters. Looking them up is straightforward.

It’s the “Parameter XYZ” is the parameter associated to the duct connector “Radius” part.