pombreda / pymel

Automatically exported from code.google.com/p/pymel
0 stars 0 forks source link

shorthand operations #179

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago

i think i've finally pieced together a set of attribute operators that i'm 
satisfied with adding to 
pymel

we got rid of our overload of __setattr__ because we did not have a similar 
shorthand for getting 
the value of an attribute.  i stumbled across a blog 
(http://xeash.net/?p=22#respond) that 
suggests an operator that i was not aware of: the unary negation operator '~'

null1.tx = 5  # set attribute to 5
a = ~null1.tx  # assign value to variable
null2.tx = ~null1.tx  # set attribute to value of another attribute

i greatly prefer this over another suggestion made in Issue 86.  

also, we should add an isConnected operator:

null1.tx >> null2.tx
null1.tx >>= null2.tx  # true

it could of course work in the reverse direction.  direction (source to 
destination) matters!

null1.tx <<= null2.tx  # false

i really like shorthand syntax for messing around in the script editor or in 
ipymel, but i don't like 
using it in modules because it is more difficult to read as one must be 
familiar with pymel idioms.  
i would prefer if there were a way that this mode had to be enabled per module 
as with the 'with' 
statement, so that each module had to add a statement like the following:

from pymel.core import shorthand

however, without overriding the import command i don't think we could get the 
callbacks we 
need for per-module control.  is there another way to control this that does 
not globally enable 
the mode for all modules?

Original issue reported on code.google.com by chad...@gmail.com on 10 Apr 2010 at 7:57

GoogleCodeExporter commented 9 years ago
Chad, im glad my suggestion in blog was helpful(sorry site now is down for a 
while),
too bad you didn't reply me about this on github though(i sent a message there 
to you
cause of oliver suggestion).
about shorthand module. why do this hard way? what is needed to do is just add
ability to write short and long syntax anywhere(even mixed) and this will be up 
to
user which one to use. this way you can write modules using long syntax and use
shorthand in script editor. 
another reason im a against importing separate module for shorthand syntax is 
it will
be over-complicated for user. just imagine : each time you want to play with
shorthand you need to import shorthand module. plus i don't think this module 
would
be so expensive for loading so its no point in doing it separately.

Original comment by gXe...@gmail.com on 25 Apr 2010 at 10:53