Today I will show some re-factoring done on my old toggle node .
Pruning rig dependencies :
This node purpose was to simplify a graph network by enabling user to toggle the state of a large number of elements.
Its usually used for common space switching setup :
- An enum attribute defines which parent is active
- All other element are then disabled
As usual on such simple node the core functionality can be written in two lines:
(notice how coding style and pep8 was not my priority nor concern)
def updateToggleStates(self): for item in self.currentDataHandleArray: item.setBool(False) self.currentDataHandleArray[self.currentActiveIndexValue].setBool(True) def compute(self, currentPlug, dataBlockInput): self.collectOutputhandle(dataBlockInput) self.prepareBuilder() self.resize(dataBlockInput) self.updateToggleStates() self.writeOutput()
On the updated code the node will resize the output attribute array with and array data builder and then write the correct value from the selected currentActiveIndexValue.
Tool design :
To help people have the least amount of preparation the primary mode of this tool will be focused on driving a parent constraint .
item can be reorder in the list with dra and drop and the text edited after a double click
Launching the tool can be done with Mayanomicon/run/openToggleParentWeightsTool.py
Final product and parting words:
Source code and tool are now available in my Mayanomicon repository
The download section will be updated accordingly and expose how module installation works.