Using Revit UI to display Dynamo Output

Hi everyone,

I’ve made a script to find imported cad files which returns with their unique element IDs and the file name. I’m using a python script which takes Revits UI to display this info in a pop-up window so that it may be used by Dynamo Player. The issue i have is the formatting of the window, ideally i’d like the IDs and Names to be in a column of their own so that way they align to the corresponding element. Issue is that the Python script can only take a single input so i have to join the strings together. Anyone know of a way to improve this? I was thinking if it were possible to make a table but don’t think that will work as the Python script is expecting a string input.

Thanks

Dynamo Output

I’ve been able to simplify the script slightly and incorporate another input to the python script so it is slightly neater but still not quite what i’m after. Any way to display these two inputs side by side?

Dynamo Output

2 Likes

Thanks Deniz, this sorted it out.

1 Like

Hi Deniz,

Hoping you may know the solution to this. That bit of script seems to break once the list is empty i.e. no more element ids, is there a way for it to return a blank value should the list be empty?

Dynamo Empty Param

IN[0] can be empty or both of them?

Both can be empty, IN[0] is the elements ID number and IN[1] is that elements file name

liste_ID, liste_n=IN

z=[]

for el, elem in zip(liste_ID, liste_n):
	i=liste_ID.index(el)
	i+=1
	if el != None and elem !=None:
		b=el+ ":" + liste_n[liste_ID.index(el)]
		z.append(b)
	elif el==None and elem !=None:
		b=""+":"+liste_n[liste_ID.index(el)]
		z.append(b)
	elif el ==None and elem ==None:
		b=""+":" +""
		z.append(b)
	else:
		b= el +":"+""
		z.append(b)
OUT=z

Hi Deniz, thank you for that but if i understand your script correctly, it is looking for nulls alongside other values. The way the script is intended to be used is to look for all imported cad files then the user to either delete most or all. When all are deleted, the list is empty which is what is giving the empty value. I assume this error is due to the list being empty instead of having ‘nulls’ in the list.

2020-01-20 09_47_26-Window

Hello Peter,

yes you are right. For that purpose I would recommend you to use “Clear List” node from Archi-lab and then connect it to previous code.

Hi Deniz,

Makes sense, however if i use the “Clear List” node from Archi-Lab on a list that is already empty, it still results in an empty list. I believe the only way around this is to use some sort of ‘IF’ statement to test whether the list is empty or not. If it’s not empty then pass through the data from the list, if it is empty then placement it with a predefined string. I’m not sure if this is possible, looking at the current “IF” node, it takes a boolean then input the values that are true and false. Sorry, still learning a lot of dynamo and python at the moment so not too savvy with all the available nodes.

Thanks to Bakery, i was able to sort it out. They have a node which is exactly as i described above. Thank you again for all your help Deniz, greatly appreciated.

1 Like

Hello Peter,

I took a look problem again and I see that it is about iteration. You should connect a list as input so as to be itterated. There are two options for that:

1- Using “List.Create” and passtrough that list, which causes that problem
2- Update the code

liste_ID, liste_n=IN

if not hasattr(liste_ID, "__iter__"):
	liste_ID= [liste_ID]
if not hasattr(liste_n, "__iter__"):
	liste_n= [liste_n]
z=[]

for el, elem in zip(liste_ID, liste_n):
	i=liste_ID.index(el)
	i+=1
	if el != None and elem !=None:
		b=el+ ":" + liste_n[liste_ID.index(el)]
		z.append(b)
	elif el==None and elem !=None:
		b=""+":"+liste_n[liste_ID.index(el)]
		z.append(b)
	elif el ==None and elem ==None:
		b=""+":" +""
		z.append(b)
	else:
		b= el +":"+""
		z.append(b)
OUT=z
1 Like

Thank you for this Deniz, I did retweak the script after that screenshot i posted and made the boolean input if false to be the output of the python script which did work in the way i wanted, e.g. empty pop-up window but it was still breaking the python script as the bakery node was outputting strings and destroying the list order. Your updated script simplifies it much more and works flawlessly, thank you.

1 Like