Wall type collector with Python

revit
python
api

#1

Hello mates, i tried to make a node that collect walls by type with python ! it works well the first time but when i add a new walls in the revit model and run the graph Nothing happen, i must deconnect the nodes run the graph then reconnect them and run the graph a second time to work ! i don’t understand why it doesn’t refresh automatically when running the graph !
some help would be great thank you :slight_smile:


#2

Hello Talbimam,

This is how the Python node works in Dynamo - It will only execute once, unless either an input is changed (Toggle the + icon) or the internal contents of the node itself have been changed (The code).


#3

Even if there is new walls in revit model ?


#4

You can use the “SpringsUI.Refresh” node to force a re-run of everything.

Personally I like coding in Visual Studio Code and use the Python Script from String, so that you do not have to close the python window on each rerun (though it does not have to be closed in Dyn 2.0) Another advantage is that you have linter.

I believe the node i mention have been integrated into the dyn 2.0 core environment


#5

@Jonathan.Olesen,

sometimes I use this, with VSCode as you mentioned


#6

Hi @talbimam @adam_bear1 @Sol_Amour @Jonathan.Olesen

How about Periodic update?


#7

hi @Kulkul it looks very cool, but how can i activate this periodic run ?


#8

It is an option in dynamo 2.0 i believe :slight_smile: nice one @Kulkul


#9

It might be better if you just use the built in node to pick up the walls and leave the graph in automatic node. The built in node subscribes to the document.Changed event and will re-execute and that will also force your python script to re-execute:


#10

@Dimitar_Venkov yes absolutly, but i should filter to take just one type of walls !


#11

You should first use “Date.Time Now” node to get periodic activated and click here:


#12

No Its not “Date.Time Now” was there in earlier version also :sunglasses:


#13

@Kulkul can i see how you used date time now in python script ?


#14

Oh have not noticed the ‘‘periodic’’ option in pre-2.0 :confused: i must have overlooked it :slight_smile: thanks :+1:

I feel blind, oh well, you learn something new every day.


#15

Bear in mind that Periodic mode will re-execute the entire graph - so if it’s heavy, it may be a slow approach while it calculates (Also - it will hit an infinite loop, i.e freeze, if the time to run the graph is longer than the period).

I would just run with @Dimitar_Venkov’s solution.


#16

You can use same script just add this at line number 21:

AutoRefresh = IN[1]

And connect Date.TimeNow node to IN[1]

Cheers!


#17

thank you !


#18

thanks @Kulkul, periodic is very cool :sunglasses:


#19

You’re welcome!


#20

WARNING: Be careful with Periodic runs. If the amount of time to re-calculate larger graphs will lead to never-ending runs if the time to execute is longer than the refresh rate.

On a more positive note: I still love this post by @Zach_Kron in the geometric formulas in design script thread. Really inspiring use of periodic runs.