Closed kalemas closed 2 weeks ago
First idea is to generate replacement pairs when switching namespace and changing shape targets, then do substitution in shape.actions.
We may substitute only words that look like absolute maya node path :|
or only string literals: node = 'pCube1'
will be changed to node = 'geom:pCube1'
.
Or explicitly define namespace in script text: cmds.getAttr('{namepsace}:pCube1.v')
.
By the way would we exec
in any useful context?
exec(code, {'cmds': maya.cmds, 'mel': maya.mel})
or application context import __main__; exec(code, vars(__main__))
or even exec(code, vars(maya.cmds))
so we would optimize our scripts using direct getAttr('pCube1.v')
and etc.
making separate field for holding a namespace in picker data would solve several cases. I still thinking about referencing pickers and if there would be such field and mechanics, it would be as easy as override single field rather than changing targets of all the shapes in #67
To reproduce, 1. reference a character, 2. setup a picker, 3. add action to, say, switch visibility, 4. load same character and change namespace picker namespace to that character namespace
visibility will be still switched on first character but nodes will be selected on second
Here is what i got
Expected to switch visibility for second character as i explicitly switched namespace for the picker.
Yeah off course it is not working ^^ as the script is an hardcoded string. It is not going to read the script and detect what could be a target or not inside the code. That seems impossible to automate. I guess your best shot is to
cmds.getAttr(f'{dwpicker._dwpicker.namespace_combo.currentText()}:cube')
I guess I should add a shortcut to set user able to do: dwpicker.active_namespace()
making separate field for holding a namespace in picker data would solve several cases. I still thinking about referencing pickers and if there would be such field and mechanics, it would be as easy as override single field rather than changing targets of all the shapes in #67
Yeah that probably a cleaner solution less hacky than how it is now.
By the way would we
exec
in any useful context?
exec(code, {'cmds': maya.cmds, 'mel': maya.mel})
or application contextimport __main__; exec(code, vars(__main__))
or evenexec(code, vars(maya.cmds))
so we would optimize our scripts using directgetAttr('pCube1.v')
and etc.
globals() is necessary, if you remove removable, it is almost impossible to execute long code. It creates a lot of "variable not defined" errors, despite you define it 2 line above. I'm affraid of predefining maya.cmds because some studio use other aliases than cmds (mc for instance). To me, using vars(main) seems even worst, because it means same picker could work or fail depend of what was imported somewhere else at some moment. You will test on your machine, it work, you provide to animator and boom, it fails because you imported in your script editor some variables during dev and not the animator.
Hi, FYI I just exposed a dwpicker.current_namespace() function which is now the safest way to gather the current namespace.
Hey I think I can close that ticket :)
To reproduce, 1. reference a character, 2. setup a picker, 3. add action to, say, switch visibility, 4. load same character and change namespace picker namespace to that character namespace
visibility will be still switched on first character but nodes will be selected on second
Here is what i got
Expected to switch visibility for second character as i explicitly switched namespace for the picker.