SetParameter periodically freeze

Hi,
With DateTime.Now, I want to change periodically one parameter of elements.
My script works when I do a Get of my parameter but, When I do a Set, Dynamo freeze
Do you have an idea?

Be very careful when doing anything in Revit with Periodic mode.

You’re only showing the get portion of your code so it’s impossible to tell what’s happening with set, but I’m guessing the issue is due to not using DateTime to control when your code runs.

If you want to run your graph periodically then you have to define what that periodic interval will be. Without a defined interval the code will run constantly. That is likely what’s happening here. Getting a parameter value doesn’t modify Revit or change any node outputs, so it runs once and is done. Setting a parameter value modifies the Revit model and forces the python node to update. This update forces Dynamo to re-execute with the new changes and gets itself into an infinite loop.

Thx for answering me.
I put a periodic interval. The picture does not figure it but I put a value : 3000ms
Each 3s, it reads the value of the param, but the problem is when I Set a value.

We still need to see the code you’re using to set the parameter value. Have you confirmed it works in Manual mode?

Yes, it works in Manual mode.
Here is my script :
Synthe_Periodic.dyn (8.9 KB)

Images would be preferred as we won’t have access to the families or instances you’re trying to manipulate. A screenshot of the whole graph, with all the node preview bubbles pinned, goes a long way.



I’ve got a family speaker with an Amplitude parameter.
When I click on Execute, the parameter change and the speaker move.
When I change to Periodically, it freeze

How many elements are you updating? Is it possible the runtime is more than 3 seconds? The code looks correct and should update periodically. I’m guessing there’s something that’s just causing your runtime to be longer than your set interval.

I’ve got 2 elements…

Hi @Sona_Architecture ,

Is there a specifc reason you are doing this with Python instead of nodes?

Hi Daan
Good question.
I try to limit as much as possible Dyamo nodes because script is graphically clearer.
But, I make a new script with a SetParameterByName and it works!
Strange…
But, have a look in this capture, Math.Random not work with Periodic whereas Random in a python script works with a link between DateTime.Now and my python script…

Hi @Sona_Architecture ,

Because of the way how Dynamo works I would assume that only nodes which receive an update, i.e. by a DateTime.Now node actually update each run. With no exceptions whether Dynamo is set to Automatic, Manual or Periodic.

Perhaps you could add an IN[1] to your python node which uses the DateTime.Now as input for that. Also, you don’t actually need code for that, just the connection is sufficient

1 Like

Thx Daan for your complement of explanation.

With regards to @Daan’s comment about “updating” nodes between runs: the input needs to change but the value does not. You can use a wait node to force these changes with DateTime.Now. As the time changes the value will be updated and all downstream nodes will have to re-execute. In your case however, it may be easier to just use Math.Random with a seed value instead. The time can be the seed and the random number will update accordingly.
DynamoSandbox_2022-07-12_08-23-09

1 Like