Skip to content

Commit 890faab

Browse files
authored
ParameterValueSource.FromType made nullable (#1558)
2 parents b1b89e2 + ca4979a commit 890faab

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

Revit_Core_Engine/Compute/TryGetValueFromSource.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public static Output<bool, object> TryGetValueFromSource(this Element element, P
5353
return null;
5454
}
5555

56-
if (valueSource.FromType)
56+
if (valueSource.FromType == true)
5757
{
5858
Element type = element.Document.GetElement(element.GetTypeId());
5959
if (type != null)
@@ -66,6 +66,13 @@ public static Output<bool, object> TryGetValueFromSource(this Element element, P
6666
}
6767

6868
Parameter param = element?.LookupParameter(valueSource.ParameterName);
69+
if (param == null && valueSource.FromType == null)
70+
{
71+
param = element.Document.GetElement(element.GetTypeId())?.LookupParameter(valueSource.ParameterName);
72+
if (param != null)
73+
BH.Engine.Base.Compute.RecordNote($"Parameter {valueSource.ParameterName} was not found in the instance of element {element.Id.IntegerValue}, but was found in the type.");
74+
}
75+
6976
if (param == null)
7077
{
7178
BH.Engine.Base.Compute.RecordNote($"Element with id {element.Id} does not have a parameter named {valueSource.ParameterName}.");

Revit_oM/Parameters/ParameterValueSource.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ public class ParameterValueSource : IValueSource
3535
[Description("Name of the parameter to extract the value from.")]
3636
public virtual string ParameterName { get; set; } = "";
3737

38-
[Description("If true, the value to be extracted from the underlying type, not the instance.")]
39-
public virtual bool FromType { get; set; } = false;
38+
[Description("If true, the value to be extracted from the underlying type, not the instance." +
39+
"\nIf set to null, first instance will be checked for the parameter with given name, and if not found then same will be done with its type.")]
40+
public virtual bool? FromType { get; set; } = null;
4041

4142
/***************************************************/
4243
}

0 commit comments

Comments
 (0)