On Sat, Oct 8, 2016 at 5:38 AM likage <[email protected]> wrote:

> Hey Justin, correct me if I am wrong on this..
>
> So while I did try using global dictionary, it only works on the first try
> too, but as soon as I close and reopen my UI, the original assignment is
> gone.. Giving me the same issue as stated in my thread.
> I must be doing something very wrong in my logic and if possible, could
> you kindly enlighten me on this?
>

In your original example, the problem that you are seeing is you are not
conditionally updating your default dict only when it doesn't have an entry
(at least not how I read it). So each time you run the code, it will just
update the dict with the current value before changing to another shader.
The logic needs to include something like this:

some_persistent_dict = {}
...
entry = 'node_name'if not entry in some_persistent_dict:
    # We have never recorded the original shader.
    some_persistent_dict[entry] = get_original_shader(entry)# Standard behavior
assign_new_shader(entry)

​

Any of your options (global dict, optionVar, file, node attributes, ...)
will require a step like this to see if the original shader needs to be
recorded. If you don't do this, you will always trample your previous value
with the current one.

Hope this helps



> I suppose using of json files work but if can be, I would not want to
> introduce in a new file creation which is solely just for containing the
> assignments.
>
> Will need to check up on optionsVars to see if it caters to my need
>
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/27ee5537-6bdc-48c3-abb0-dacc403af448%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/27ee5537-6bdc-48c3-abb0-dacc403af448%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA2ijR_DPDoF95ir-0ZOycwuz1tJoZPW4qPVpKFWbEbhug%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to