Different results with using a Custum node in Dynamo Window and Dynamo Player

Guys,
I’m confused why I get different results when using a Custom Node.

Here is my script.
The script presents 3 ways to select elements by Assembly Code
option1: use Nodes to select
option2: use Nodes with Python to select
option3: use a Custom Node with used nodes as in option1

I’ve tried to count element by running the script in Dynamo windows
Then I copied some elements and run it again.
It gives a wrong answer when working with custom node when running in Dynamo windows.
But it gives the right answer when running in Dynamo Player

Huh? What?

Can anybody explain how to fix this?
test 2022 - select assembly code.dyn (57.9 KB)

Might have something to do with Dynamo not refreshing if you edit something in Revit while having the script open?

Do you get the correct results if you close Dynamo, open it again and run it?

I think you could add a ‘transaction end’ and ‘transaction start’ node to make sure dynamo picks up on your newly added elements.

In my script i’m only counting elements.
Counting elements fails when i copy elements before i start the script again in Dynamo windows.
Is 'transaction end’ and ‘transaction start’ still necessary?
But I will give it a try. :slight_smile:

How did you create the custom node? Dynamo does not always translate it correctly or mixes things up. I would suggest that you go into the edit window of the custom node and check it by yourself for errors. Had the same issue several times especially when the nodes that where hand over to a custom node where wired quite complicated.

The custom node works… the counting is alway correct via Dynamo Player. But it’s not always correct when running in Dynamo window when the model (=database) is changed.

Then it should have something to do with the fact that dynamo does not always reruns every node. For example:

You import data from an excel file and calculate something and everything works fine. If you now change something in the excel-file it won’t affect your calculations in dynamo as it won’t rerun the import. Only if you close dynamo, change the filepath or disconnect->run->connect->run it will consider the changes.

Yes. That’s exact the same issue i have too. But as I said: this issue only happens in Dynamo windows. Not in Dynamo Player.

Probably a bug / Problem not solved ?

It’s because Dynamo player starts a new session of Dynamo every run. If you have Dynamo open, run your graph, make changes in Revit, then run the same graph again without closing/reopening then you could have element binding issues or just outdated data. It’s technically working as intended, it’s just that you haven’t given Dynamo a chance to update its information.

You have a few options for avoiding this:

  1. Close and reopen between runs. This is the tried and true method that should always work.
  2. Disconnect something at the beginning of your graph and run once with your graph (presumably) failing. This is to cause a change that will force Dynamo to reevaluate all the nodes. Then just reconnect and run again.
  3. Make a change to an early node rather than completely disconnecting. Replacing a node (even with the exact same data) should also work. This is the same idea as Option 2, to force a reevaluation of nodes.

Thanks for the extra information !
But I still want to know why it will not work with custom nodes. The rest works.

I think he told you why :slight_smile:
It’s due to element binding, he also gave you some solutions to work it out.

Sorry. My mistake.
@MVE1112 /@Nick_Boyts : Thanks for the info. :+1: