State:New|TargetRelease:No Target|icon_bug|icon_katana|database:public|Resolution:Fixed|BugID:358694|
Problem summary
On document load, polish() is called on a Group node before its contents (child nodes) are created. Therefore, parameters of internal nodes cannot be accessed from a custom `polish()` function.
Our current documentation isn't clear on this: it doesn't say that `polish()` is called before a SuperTool node's internals are populated:
https://learn.foundry.com/katana/dev-guide/Scripting/CustomizingNodeTypes/CustomNodeTypes/SuperTools.html#NodegraphAPI.SuperTool.polish
```
polish()
This method is automatically called on the SuperTool after it has finished loading and initialization. It will only be called once.
```
That's a little misleading. The original intent may have been for `polish()` to be called only after child nodes have been created. Having the polish function run before the SuperTools node’s renders the polish function useless on document load.
Customer reported version
katana.3.0v1
Customer reported platform
centos7
Steps to reproduce
1) Add the attached HelloSuperToolNode SuperTool to your Katana resources. The polish function has the following code:
```
def polish(self):
print "Number of nodes on polish() ", len(NodegraphAPI.GetAllNodes(False,True))
for node in NodegraphAPI.GetAllNodes(False, True):
print node
```
2) In a new katana project, add a HelloSuperToolNode. Notice in the console the number of nodes is 2.
3) Save the project as "polish_test.katana"
4) Open "polish_test.katana". Notice in the console the number of nodes is 0.
5) Run the following command in the Python tab: NodegraphAPI.GetNode('HelloSuperTool').polish() Notice the number of nodes is 3.
Result: On document load, `polish()`does not have access to its childnodes.
Workaround
A possible workaround to edit the child nodes of a SuperTool node at document load is to create an onSceneLoad callback that calls the polish() function. Although, one should make sure to add a sentinel in polish() to not run when automatically called on document load. One way is to check if the node hierarchy has been loaded:
```
def polish(self):
if len(NodegraphAPI.GetAllNodes(False,True)) == 0:
return
...
```
Reproduced by support
This bug has been reproduced in:
Katana3.0v2 - Windows 10, CentOs 7
Katana3.0v1 - Windows 10, CentOs 7
Katana2.6v4 - Windows 10, CentOs 7
Katana2.6v1 - Windows 10, CentOs 7
Katana2.5v7 - Windows 10, CentOs 7
Katana2.5v1 - Windows 10, CentOs 7
Katana2.1v6 - CentOs 7
Katana2.1v1 - CentOs 7
Katana2.0v5 - CentOs 7
Katana2.0v1 - CentOs 7
Katana1.6v3 - CentOs 7
Earliest version tested
- This issue appears to be in all versions of the product
Expected behaviour
The ‘polish()` function should be called only after child nodes have been created.
Actual behaviour
On document load, `polish()` is called on a Group node before its contents (child nodes) are created.
We're sorry to hear that
Please tell us why