Dynamo icon indicating copy to clipboard operation
Dynamo copied to clipboard

Access to Key of KeyValuePair not possible with Python Interpreter

Open tinrobot2000 opened this issue 2 years ago • 1 comments

Dynamo Version

2.18.1

Host

Revit 24.1.0.66 20230701_1515(x64) 2024.1.0

Operating System

Windows 10

What did you do?

Trying to get the Key for the BindingMap always throws an exception OUT = doc.ParameterBindings.ForwardIterator().Key

What did you expect to see?

A ParameterGroup, or at least a string

What did you see instead?

image

What packages or external references (if any) were used?

None

Stack Trace

No response

Details

EDIT You can retrieve some information sp = SharedParameterElement CPython3 doc.ParameterBindings.get_Item(sp.GetDefinition()) IronPython doc.ParameterBindings.Item[sp.GetDefinition()]

EDIT 2 Workaround

# CPython3
params = FilteredElementCollector(doc).OfClass(ParameterElement).ToElements()

def get_binding(param):
    binding = doc.ParameterBindings.get_Item(param.GetDefinition())
    if binding:
        return param.GetDefinition().Name, binding

OUT = filter(None, [get_binding(p) for p in params])

tinrobot2000 avatar Dec 09 '23 23:12 tinrobot2000

Thank you for submitting the issue to us. We are sorry to see you get stuck with your workflow. While waiting for our team member to respond, please feel free to browse our forum at https://forum.dynamobim.com/ for more Dynamo related information.

github-actions[bot] avatar Dec 09 '23 23:12 github-actions[bot]