Wall type collector with Python

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:
Capture

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).

1 Like

Even if there is new walls in revit model ?

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

1 Like

@Jonathan.Olesen,

sometimes I use this, with VSCode as you mentioned

Hi @talbimam @adam_bear1 @solamour @Jonathan.Olesen

How about Periodic update?

3 Likes

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

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

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:

2 Likes

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

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

2 Likes

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

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

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.

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.

5 Likes

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

AutoRefresh = IN[1]

And connect Date.TimeNow node to IN[1]

Cheers!

1 Like

thank you !

thanks @Kulkul, periodic is very cool :sunglasses:

1 Like

You’re welcome!

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.

2 Likes