hello simple question, how to know which Elements Parameter Value is not inserted/filled/existing?
I tried to ask if the parameter value is nothing string “”, asking if list is empty, asking if the Elements Parameter is Null, not sure if there is a clearer way to know.
In this stupid test case, the elements do not have the parameter asked
I want to check if exist to know if the parameter has been applied correctly the Revit categories expected.
I want to check if there is a parameter value because taking different actions afterwards.
I used parameter is null, parameter has value with boolean filters in between in 2 stages, and I was asking if that is a wird thing to operate or perhaps there is a quick way straight forward.
My test here:
You can detect if a list or sublist is empty by comparing it´s length with 0.
To check if a list item is empty, you can compare the chars in the corresponding str with 0.
Code example:
TestDYN.dyn (5.6 KB)
list = IN[0]
result =[]
text = len(str(list[0][0]))
text1 = len(str(list[0][8]))
test = bool
if text1 >=0:
test = True
else:
test = False
OUT = "Length of first list: " + str(len(list)), "Length of sublist: "+ str(len(list[0])), "Number of chars (1st list item): " + str(text), "Number of chars (8th list item): " + str(text1), "is item 8th empty? : " + str(test)
With nodes there is certainly also a suitable way.
1 Like
A nonexistent parameter and a blank value will both return an empty string (""). In order to check if the parameter exists first, you’ll have to use python and the Revit API.
That being said, why do you need to differentiate the two? Assuming you’re going to eventually write to that parameter, it won’t matter if the parameter doesn’t exist.
I want to check if exist to know if the parameter has been applied correctly the Revit categories expected.
I want to check if there is a parameter value because taking different actions afterwards.
I used parameter is null, parameter has value with boolean filters in between in 2 stages, and I was asking if that is a wird thing to operate or perhaps there is a quick way straight forward.
But what happens if the parameter has not been applied to the categories as expected? It seems like you’re applying project parameters so it’s all or nothing already. If you’re applying them to individual families then that’s different, but it might make more sense to fix those families in a separate script or just go ahead and apply it to all families of a given category at that point.
As I mentioned, nonexistent parameters and blank values for existing parameters will both return an empty string (""). There’s no way to differentiate them based on the returned value. You have to check whether the parameter itself exists in that case. I think your confusion is from using a !=
node instead of a ==
node.
string does not work if parameter does not exist, I show that in my screenshot sample
It actually does though. You’re using a “does not equal” node, so it’s saying that the value is not not an empty string. You want to use the ==
node.
same result but opposite? but non existing parameter returns false
What are you seeing? This shows a valid parameter, invalid parameter, and empty parameter.
1 Like
thanks, will try but that was the first thing I did and it was not correct result, then looking more alternatives.