ModifierΒΆ
The Modifier package provides the base frame work for Document modification
To perform Document modification, one must use a modification context, also called a Document Modifier. This package provides the base API to create, delete and modify nodes and plugs in the Document and keep track of undoable actions at the same time.
To start a new modification context, use the Document:modify () method:
-- Start a document modification
local mod = Document:modify ()
-- Create a child in the Document
local node = mod.createnode (Document, "Node", "MyNode")
-- Create a plug in the child node
local plug = mod.createplug ("Plug", node, "MyPlug", Plug.Dynamic, types.string, "Default")
-- Finish the modification and stack all actions in the undo/redo stack
mod.finish ()
Additionnally, it is possible to query the Document for the current modification context. This is useful if you have nested function calls that perform modifications.
local function createnode (parent)
-- Get the current modification context
local mod = Document:getmodifier ()
return mod.createnode (parent, "Node", "MyNode")
end
-- Start a document modification
local mod = Document:modify ()
-- Create a child in the Document
local node = createnode (Document)
-- Create a child in the child
local child = createnode (node)
mod.finish ()
Note that when querying the current modification context, some actions are not permitted, such as select, createref and deleteref.
Functions:
| Modifier.adddependency | (
|
Adds dependency of an output plug on an input plug |
| Modifier.connect | (
|
Connects a output plug to an input plug |
| Modifier.createnode | (
|
Create a node in another node |
| Modifier.createplug | (
|
Creates a plug in a modification context |
| Modifier.createref | (
|
Creates a reference |
| Modifier.deletenode | (
|
Deletes a node from its parent |
| Modifier.deleteplug | (
|
Deletes a plug from a node |
| Modifier.deleteref | (
|
Deletes a reference |
| Modifier.disconnect | (
|
Disconnects a plug from another |
| Modifier.movenode | (
|
Moves a node from a parent to another |
| Modifier.removealldependencies | (
|
Removes dependency of all plugs on this plug |
| Modifier.removedependency | (
|
Removes dependency of an output plug off an input plug |
| Modifier.renamenode | (
|
Renames a node |
| Modifier.select | (
|
Changes the current document selection |
| Modifier.set | (
|
Sets a plug value |
| Modifier.setclass | (
|
Changes the class of a node |
| Modifier.settype | (
|
Sets a plug type |
| Modifier.touch | (
|
Invalidates a plug |
- Modifier.adddependency
- Modifier.connect
- Modifier.createnode
- Modifier.createplug
- Modifier.createref
- Modifier.deletenode
- Modifier.deleteplug
- Modifier.deleteref
- Modifier.disconnect
- Modifier.movenode
- Modifier.removealldependencies
- Modifier.removedependency
- Modifier.renamenode
- Modifier.select
- Modifier.set
- Modifier.setclass
- Modifier.settype
- Modifier.touch