Bool when parameter has no value

Hi all,

I just started with python that’s why so many questions :slight_smile:
How can I get a bool when my paramater has no value?

#alle elementen van OST category ophalen
alleElementen = RDB.FilteredElementCollector(doc)
alleElementen.OfCategory(RDB.BuiltInCategory.OST_PipeCurves)
alleElementen.WhereElementIsNotElementType()

#ID ophalen voor parameter
ID = alleElementen.ToElementIds()

ParameterNaam="bouwnummer"

param = list()

for MyE in alleElementen:
	try:
		param.append(get_parameter_value_by_name(MyE, ParameterNaam))
	except:
		param.append(None)
		


bool = list()

for check in param:
	if check == None:
		bool.append(True)
	else:
		bool.append(False)

OUT= param, bool

I tried to use this methods, (after create a string)

for check in param:
	if check == " ":
		bool.append(True)
	else:
		bool.append(False)
for check in param:
	if check > 0:
		bool.append(True)
	else:
		bool.append(False)

Thanks in advance

using OOTB nodes- Object.IsNull ?
there is probably a Python isnull function- definitely a Pandas one

Thanks for you’re answer.
I know the node but I don’t know how to get it in python.

I tried to build a script in Python without any other nodes :slight_smile:

I don’t think Python libraries such as Pandas work in Dynamo (IronPython)- but I’m sure one of the Python experts on this forum will have an answer

1 Like

Hmm now it works fine. I don’t know or this is the right way to do…

bool = list()

for check in param:
	if check == "":
		bool.append(True)
	else:
		bool.append(False)

1 Like

Having no value would generally mean that it would have a null value, an “empty string” like "" is not really the same.
I think that your problem should be pretty easy to solve, but I’m not sure what your question is.

Does it work if you replace " " with [ ]

[] would result in an empty list, that’s not quite the same. None in Python would be the equivalent of null I think.

1 Like

If it is a text (string) parameter it might be better to check for zero length
if(len(parameter) == 0)

1 Like

@PauLtus
What I want is check the parameter values.
I want a true if the parameter is not filled.

image

@Andrew_Hannell
You’re way works, thanks for that.

What is the safest way to check the value?

O!
Then your method checking for "" works just fine. It will read it as an empty string, which, technically speaking still has a value. Think of it as the string equivalent of 0.

1 Like

@jw.vanasselt

Hi.

You can use the HasValue property:
Parameter Class (revitapidocs.com)

Regards,

@Organon thanks!

Does someone know how I can create a group in python like the group by key in dynamo?

1 Like

That’s a new question, better to make it a new topic.

1 Like

You’re right sorry :wink: