0
down vote
favorite
Was wondering if anyone has any good ways for approaching this problem of mine…
I have a few rigs in which it is a reference. I am trying to do some shader-assignment that targets for a certain name in these rigs.
In my UI, if the user selects a certain color in the combobox, it will create a new shader and assign to the geos within that rig(s). And if it selects the first index of the combobox which is a blank, it will reassign those geos back to shaders that it was initially assigned.
For example, I have a test_geo (this is a reference) and it comes with a “test_geoShader (lambert)”. If I select any other color, the connect between the test_geo and test_geoShader will be disconnected and it will be assigned with a new shader, eg. newShader (lambert) If I select the ‘blanked’ option, it will disconnect test_geo with the new shader and assigned back to test_geoShader
However, my code (pls see below) only works on the first try to get the original assignment… Meaning to say if I open my UI the first time, did some new shader assignments, close and reopen my UI, it will pick up the current assignment it has as the original assignment…
Any suggestions in approaching this? And is it possible to do so without creating any new files (json etc…) to store the data?
def get_orig_shader(self, nodes_list):
orig_shader_dict = {}
for node_name in nodes_list:
node_shapes = get_shape(node_name)
for node in node_shapes:
if "defaultPtx" in node:
shading_grps = cmds.listConnections(node, type='shadingEngine')
shaders = cmds.ls(cmds.listConnections(shading_grps), materials=1)
orig_shader_dict[node] = shaders[0]