GetParameterValueByName for Phases from Mass Surface Types

I am trying to determine the phases for a mass surface type (glazing in this instance). I am using to “Element.GetParameterValueByName” to find the “Phase Created” & “Phase Demolished” parameters for each “Mass Glazing” surface. If the elements are not to be demolished at any point (i.e. they form part of the proposed building) then the “Phase Demolished” parameter value will be “None” or null.

In my particular example, if the 1st element has “None” for it’s “Phase Demolished” parameter then I cannot retrieve any phase parameters for the rest of the list. However, if the 1st element does have a parameter value for “Phase Demolished” then the entire list of phase name populates, despite some of the other parameters containing the “None” value. To summarise, if the 1st value in the list is “None”, the entire output fails but if the value is anything else, the entire output works.

I hate this issue cuz every time it comes up I have to bang my head against a wall. You need to either feed in something which doesn’t return null as the first item, or force Dynamo to evaluate conditions instead of just reporting values.

The former can be done by inserting a known demolished object to the front of the list.

You can try the later with a code block like this, though I’m away from the desk so I can’t confirm it works. (specifically blanking on the parameter name for phase demolished). There are also ways to use Python for this.

Elem.GetParameterValueByName(“Phase Demoliahed”)!=null? Elem.GetParameterValueByName(“Phase Demoliahed”): null