Nyro
11-25-2010, 02:37 PM
Hey there,
I'm currently writing my first more or less useful piece of code attached to a custom GUI.
This project is presenting me with challenges at every second line of code, which keeps the process fun but makes for a rather tedious experience.
Anyhow, here's just one of the many problems I've encountered for which I haven't really found a workaround, so I'm asking the Pros :)
How do I keep track of a node's name, even after that node has been renamed?
There's a wonderful pre-defined scriptJob event that I can attach to my node, triggering whenever said node changes its name.
Example:
string $myNode = "pSphere1";
scriptJob -nnc $myNode "print(\"Node name changed!\")";
So far, so good. I know when the node get's renamed. The problem is, there is no way for me to tell what the node's name currently is.
I'd have to query that node, but since the name isn't the same as before, I can't point to it.
Interestingly, the scriptJob command seems to be able to keep track of the node, no matter what its current name is, since it obviously triggers after arbitrary rename operations.
Here's the more specific problem:
I have a GUI, which lets the user create a set of objects. These objects are grouped under a groupnode (transform), let's say it's called "ObjectGroup_1".
The GUI lets the user run a script which manipulates the created objects. The script only knows which objects to operate on by querying the children of the group "ObjectGroup_1" (and some other conditions, but they aren't relevant).
The problem is: node names are not bound to any kind of attribute, all the way up to the depency node. So there is no way of locking the (fictional) name attribute to prevent the user from renaming the group node.
So if the users goes ahead and for some reason changes the group's name, then the script will fail at subsequent calls to the old group name. Thing is, I don't want to prevent the user from renaming the group, which could be done easily by simply attaching a rename command to the scriptJob which would revert to the 'old' name. The user should not be restricted from chosing what name he deems appropriate for his DAG objects.
So what I thought I could do is: create a scriptJob together with the group node, attached to the GUI, that triggers whenever the group node's name changes. Then report the new name back to the GUI to pass along to the script.
The problem: I can't think of a way to find out what the group's name has been changed to.
How does the scriptJob itself do it?
I'd be really grateful if someone came up with some hint at a solution.
It's little problems like these that seem to be consuming an uproportional amount of development time, which isn't really acceptable (the main, complex script function was a matter of a few hours; the GUI and waterproofing/crosschecking is taking up days).
I'm currently writing my first more or less useful piece of code attached to a custom GUI.
This project is presenting me with challenges at every second line of code, which keeps the process fun but makes for a rather tedious experience.
Anyhow, here's just one of the many problems I've encountered for which I haven't really found a workaround, so I'm asking the Pros :)
How do I keep track of a node's name, even after that node has been renamed?
There's a wonderful pre-defined scriptJob event that I can attach to my node, triggering whenever said node changes its name.
Example:
string $myNode = "pSphere1";
scriptJob -nnc $myNode "print(\"Node name changed!\")";
So far, so good. I know when the node get's renamed. The problem is, there is no way for me to tell what the node's name currently is.
I'd have to query that node, but since the name isn't the same as before, I can't point to it.
Interestingly, the scriptJob command seems to be able to keep track of the node, no matter what its current name is, since it obviously triggers after arbitrary rename operations.
Here's the more specific problem:
I have a GUI, which lets the user create a set of objects. These objects are grouped under a groupnode (transform), let's say it's called "ObjectGroup_1".
The GUI lets the user run a script which manipulates the created objects. The script only knows which objects to operate on by querying the children of the group "ObjectGroup_1" (and some other conditions, but they aren't relevant).
The problem is: node names are not bound to any kind of attribute, all the way up to the depency node. So there is no way of locking the (fictional) name attribute to prevent the user from renaming the group node.
So if the users goes ahead and for some reason changes the group's name, then the script will fail at subsequent calls to the old group name. Thing is, I don't want to prevent the user from renaming the group, which could be done easily by simply attaching a rename command to the scriptJob which would revert to the 'old' name. The user should not be restricted from chosing what name he deems appropriate for his DAG objects.
So what I thought I could do is: create a scriptJob together with the group node, attached to the GUI, that triggers whenever the group node's name changes. Then report the new name back to the GUI to pass along to the script.
The problem: I can't think of a way to find out what the group's name has been changed to.
How does the scriptJob itself do it?
I'd be really grateful if someone came up with some hint at a solution.
It's little problems like these that seem to be consuming an uproportional amount of development time, which isn't really acceptable (the main, complex script function was a matter of a few hours; the GUI and waterproofing/crosschecking is taking up days).
