NatronGitHub / Natron

Open-source video compositing software. Node-graph based. Similar in functionalities to Adobe After Effects and Nuke by The Foundry.
http://NatronGitHub.github.io
GNU General Public License v2.0
4.56k stars 333 forks source link

(Bug): Python can't test oneNode == another node #777

Open bonalex01dev opened 2 years ago

bonalex01dev commented 2 years ago

Make sure to follow our issue report guidelines

Natron version

natron 2.4.1

Operating system

win10

System specs

32gb i7 rtx2070

Did you install Natron using the official installer?

Custom installation path

No response

What were you trying to do?

in Python compare if 2 nodes stored in variables point to the same node.

What did you expect to happen? What happened instead?

I expect that if I get an Effect object by predeclared variable, from selection, from group.getChildren. I could compare like this if effect1var == effect2var

But it always return false

I can use workaround to compare Labels or ScriptNames. But this is cumbersome especially for nodes nested in groups. Plus a node list stored becomes obsolete if the user renames any node.

Is it the intended behavior ? Can you think of any workaround

Step-by-step reproduction instructions

create node named "node2"

mn = app1.getNode('node2') print mn.getScriptName() sel = app1.node2 print mn.getScriptName() print mn == sel

result is node2 node2 False

I expected yhe test would return True

Additional details

I'm working on a "paste nodes" scripts that will allow the pasted nodes to be automatically inserted in the node tree. It's the default behavior in that "other compositing software" and is darn handy :-)

By the way I made a new PR in the community scripts if someone can check it...

devernay commented 2 years ago

This could be fixed (to be checked) when we switch to Qt5, thanks to the fix made for https://bugreports.qt.io/browse/PYSIDE-74 in PySide 5.15.1:

bonalex01dev commented 2 years ago

Oh nice! If I get you right and want to be ready for the future: I should implement an is_equal(effect1, effect2) function that actually compare the effects scriptnames and check if the parent group is the same... later replaced by "==" Oh by the way, I can't find a function to get the group of a node... and I can't test if node1 is in group.getChildren() because of the bug we are discussing here. Am I right ?

Anyway thanks for your reply, and good to see you back here :-)

devernay commented 2 years ago

I think implementing is_equal() as you suggest is a good fix (and will continue working even when we have ==) Please paste the implementation here.

bonalex01dev commented 2 years ago

Any hint about how to determine the parent group of a node ? If we don't have this, should we create a "unique ID" hidden parameter for each node ? Even a "parent name" parameter would fall back on the same issue ...