VFX with Natron - E0085 - Powerful & Dangerous Python Expressions

Published: 16 June 2021
on channel: Peanut Butter and Natron
838
28

In this episode we are going to explore deeper into the rabbit hole of Natron's python expressions and how powerful, and potentially dangerous a node expression can actually be by having a single node take control of the program to do some thing as simple as create other nodes. It's not limited to just this, however, it can also rewire the entire node graph, remove nodes or even create and control other instances of the Natron application it self; however, we must use caution as well, because nodes refresh all the time, and if we let the node refresh continuously it could create so many nodes that it overwhelms the program. So we will explore how we can lock the node to only do what we want one time.

Contents:
0:00:00 - Intro
0:00:16 - Preamble
0:01:32 - Setting up the stream
0:01:50 - Why I love the text node for expressions
0:02:25 - Exploring the expressions dialog
0:03:44 - What are thisGroup and thisNode?
0:04:53 - Stringing things along with STR()
0:05:30 - thisNode an Effect object
0:06:04 - thisGroup can be the GuiApp object (WOW!)
0:06:48 - Understanding the SCOPE of this
0:07:52 - A look inside a GROUP for scope
0:09:24 - Two nodes named the same but isolated by their groups scope
0:10:27 - What is the difference in a groups scope?
0:10:39 - At project level thisGroup is the GuiApp
0:10:45 - In a group thisGroup is an Effect
0:11:20 - A GuiApp thisGroup is far more powerful!
0:11:29 - We can make Plugins with the power of the app!
0:12:00 - Exploring thisGroup at the project level.
0:12:15 - The obvious group stuff like getChildren()
0:12:50 - A list of a project Nodes
0:13:28 - Not easily readable
0:14:14 - The "three" things a group is
0:14:18 - A group is a Group (always)
0:14:28 - A group is the GuiApp (at the project level)
0:14:35 - A group is also the App (at the project level because GuiApp inherits the App)
0:14:46 - Lets create a thisApp "definition" so we don't confuse talking about it with a group
0:15:45 - A variable to hold a list of nodes
0:17:00 - Is thisNode in the list?
0:18:31 - This is why node Label name is important and must be unique
0:18:42 - How to look at each node in the list
0:20:13 - Looking at a nodes name using getLabel()
0:20:44 - Now thisNode is found in the list
0:22:13 - Changing the name of our "out" variable to "tn" (temporary & skippable)
0:24:15 - Rearranging for self satisfaction to find a specific node by it's name (skippable)
0:25:45 - What are "Infinite" loops (VERY, VERY important information)
0:27:23 - Why? We are going to have our code: make a new node, and don't want multiple.
0:27:55 - A node lock variable
0:28:21 - The "lock" must be outside our code to prevent the code from resetting it.
0:28:25 - In the past we used other nodes, but now we want it self contained
0:29:38 - We want a user property
0:30:30 - Why we are now switching to a group node
0:30:43 - Flubbing up the creation of our initial parameters (skippable)
0:35:44 - Pretend Group2 is Group1, and Create our initial user parameters ;)
0:37:24 - Why do we have Code, Feedback and Loop Lock?
0:37:55 - Copy the expression from the Text node to the Group node
0:38:32 - Switching our output destination from (Ret) to Feedback (optional, but useful)
0:41:05 - Why is isolating the expression code from the feedback dialog potentially useful?
0:41:20 - Hiding, unhiding and rearranging user parameters
0:43:36 - Verifying thisApp is the GuiApp at the project level (outside) of a group node.
0:45:00 - Time to turn our "tn" variable into our loop lock
0:51:16 - Time to create a lock test (to show why we need a lock)
0:55:44 - Setting (cnt) to our Counter parameter and incrementing it each Natron refreshes.
0:56:59 - Verifying that our Counter increments every time Natron's UI updates (the problem)
0:57:49 - How the loop counter works (quickly)
0:59:21 - Because we are not locking we would have created X number of nodes
1:01:53 - Rename "tn" variable to "lock" so it's accurate
1:02:16 - Goal, if the "lock" is unlocked then run the code and lock the "lock".
1:05:05 - lock the "lock" (Finally!)
1:07:05 - "False" Feedback shows the "lock" was successful (Whew!!!)
1:09:08 - Our node could now make another node!
1:09:22 - Save our project
1:11:17 - How Natron calls an Effect
1:13:00 - Time to crash Natron (Don't do this! skippable)
1:16:14 - Reloaded & continue
1:17:00 - thisNode.getPluginID()
1:18:11 - createNode(pluginID, majorVersion...) (Note: this is an App command)
1:20:55 - A look at Natrons webdocs API for App, Group and GuiApp
1:23:03 - Finishing the node creation expression
1:23:48 - A new node created buy our group node
1:24:30 - Summery and discussion of the potential
1:28:40 - How this effects the script editor
1:30:23 - My dislike of scripts and preference to Nodes doing script like functions
1:31:10 - Stuff
1:02:55 - Thanks for watching and outro

There are currently no project files currently associated with this video.

Live stream from June 12, 2021

With: Pirate Bill


Watch video VFX with Natron - E0085 - Powerful & Dangerous Python Expressions online without registration, duration hours minute second in high quality. This video was added by user Peanut Butter and Natron 16 June 2021, don't forget to share it with your friends and acquaintances, it has been viewed on our site 838 once and liked it 28 people.