|
6 | 6 | if bpy.app.version < (4, 0, 0): |
7 | 7 | from bpy.types import NodeSocketInterface |
8 | 8 | else: |
9 | | - from bpy.types import NodeTreeInterfaceItem, NodeTreeInterfacePanel, NodeTreeInterfaceSocket |
| 9 | + from bpy.types import NodeTreeInterfacePanel, NodeTreeInterfaceSocket |
| 10 | + from bpy.types import NodeTreeInterfaceItem |
10 | 11 |
|
11 | 12 | import os |
12 | 13 | from typing import TextIO |
| 14 | +import shutil |
13 | 15 |
|
14 | 16 | from .ntp_node_tree import NTP_NodeTree |
15 | 17 | from .utils import * |
@@ -179,11 +181,15 @@ def dfs(nt: NodeTree) -> None: |
179 | 181 |
|
180 | 182 | return result |
181 | 183 |
|
182 | | - |
183 | 184 | def _process_group_node_tree(self, node: Node, node_var: str, inner: str |
184 | 185 | ) -> None: |
185 | 186 | """ |
186 | 187 | Processes node tree of group node if one is present |
| 188 | +
|
| 189 | + Parameters: |
| 190 | + node (Node): the group node |
| 191 | + node_var (str): variable for the group node |
| 192 | + inner (str): indentation |
187 | 193 | """ |
188 | 194 | node_tree = node.node_tree |
189 | 195 | if node_tree is None: |
@@ -438,6 +444,8 @@ def _set_tree_socket_defaults(self, socket_interface: NodeTreeInterfaceSocket, |
438 | 444 | """ |
439 | 445 | Set a node tree input/output's default properties if they exist |
440 | 446 |
|
| 447 | + Helper function to _create_socket() |
| 448 | +
|
441 | 449 | Parameters: |
442 | 450 | socket_interface (NodeTreeInterfaceSocket): socket interface associated |
443 | 451 | with the input/output |
@@ -472,6 +480,20 @@ def _create_socket(self, inner: str, socket: NodeTreeInterfaceSocket, |
472 | 480 | parent: NodeTreeInterfacePanel, |
473 | 481 | panel_dict: dict[NodeTreeInterfacePanel, str], |
474 | 482 | ntp_nt: NTP_NodeTree) -> None: |
| 483 | + """ |
| 484 | + Initialize a new tree socket |
| 485 | +
|
| 486 | + Helper function to _process_items() |
| 487 | +
|
| 488 | + Parameters: |
| 489 | + inner (str): indentation string |
| 490 | + socket (NodeTreeInterfaceSocket): the socket to recreate |
| 491 | + parent (NodeTreeInterfacePanel): parent panel of the socket |
| 492 | + (possibly None) |
| 493 | + panel_dict (dict[NodeTreeInterfacePanel, str]: panel -> variable |
| 494 | + ntp_nt (NTP_NodeTree): owner of the socket |
| 495 | + """ |
| 496 | + |
475 | 497 | self._write(f"{inner}#Socket {socket.name}\n") |
476 | 498 | # initialization |
477 | 499 | socket_var = self._create_var(socket.name + "_socket") |
@@ -547,6 +569,22 @@ def _create_panel(self, inner: str, panel: NodeTreeInterfacePanel, |
547 | 569 | panel_dict: dict[NodeTreeInterfacePanel], |
548 | 570 | items_processed: set[NodeTreeInterfacePanel], |
549 | 571 | parent: NodeTreeInterfacePanel, ntp_nt: NTP_NodeTree): |
| 572 | + """ |
| 573 | + Initialize a new tree panel and its subitems |
| 574 | +
|
| 575 | + Helper function to _process_items() |
| 576 | +
|
| 577 | + Parameters: |
| 578 | + inner (str): indentation string |
| 579 | + panel (NodeTreeInterfacePanel): the panel to recreate |
| 580 | + panel_dict (dict[NodeTreeInterfacePanel, str]: panel -> variable |
| 581 | + items_processed (set[NodeTreeInterfacePanel]): set of already |
| 582 | + processed items, so none are done twice |
| 583 | + parent (NodeTreeInterfacePanel): parent panel of the socket |
| 584 | + (possibly None) |
| 585 | + ntp_nt (NTP_NodeTree): owner of the socket |
| 586 | + """ |
| 587 | + |
550 | 588 | self._write(f"{inner}#Panel {panel.name}\n") |
551 | 589 |
|
552 | 590 | panel_var = self._create_var(panel.name + "_panel") |
@@ -587,6 +625,21 @@ def _process_items(self, inner: str, parent: NodeTreeInterfacePanel, |
587 | 625 | panel_dict: dict[NodeTreeInterfacePanel], |
588 | 626 | items_processed: set[NodeTreeInterfacePanel], |
589 | 627 | ntp_nt: NTP_NodeTree) -> None: |
| 628 | + """ |
| 629 | + Recursive function to process all node tree interface items in a |
| 630 | + given layer |
| 631 | +
|
| 632 | + Helper function to _tree_interface_settings() |
| 633 | +
|
| 634 | + Parameters: |
| 635 | + inner (str): indentation string |
| 636 | + parent (NodeTreeInterfacePanel): parent panel of the layer |
| 637 | + (possibly None to signify the base) |
| 638 | + panel_dict (dict[NodeTreeInterfacePanel, str]: panel -> variable |
| 639 | + items_processed (set[NodeTreeInterfacePanel]): set of already |
| 640 | + processed items, so none are done twice |
| 641 | + ntp_nt (NTP_NodeTree): owner of the socket |
| 642 | + """ |
590 | 643 | if parent is None: |
591 | 644 | items = ntp_nt.node_tree.interface.items_tree |
592 | 645 | else: |
|
0 commit comments