public static CustomVariable GetCustomVariableFromNosOrElement(ElementRuntime elementRuntime, string variableName)
{
CustomVariable variable = elementRuntime.AssociatedIElement.GetCustomVariableRecursively(variableName);
if (variable != null)
{
// The NOS may be overwriting the value from the element, so we need to set that if so:
if (elementRuntime.AssociatedNamedObjectSave != null)
{
NamedObjectSave nos = elementRuntime.AssociatedNamedObjectSave;
InstructionSave instruction = nos.GetInstructionFromMember(variable.Name);
if (instruction != null && instruction.Value != null)
{
variable = variable.Clone();
variable.DefaultValue = instruction.Value;
}
}
}
return variable;
}