How To Get The Compound Attribute In Maya
· Def:-
Compound attributes has multiple sub-attributes split by '.' . What is the best way to extract attribute part from its node part.
Few of the many ways are mentioned below.
· Using nodeAttr and plugAttr command from maya.mel
· Using partition method on string
· Using split method on string
· Tip:-
· nodeAttr and plugAttr command :- this method will require importing of the module or
selective command imports from module which is not so efficient idea.
· split method:- much more efficient than nodeAttr and plugAttr commands.
· partition method:- most efficient of all. For attribute splitting partition is the best method to avail.
· Code:-
Code comparison betwen partition and split methods.
· Partition Method:- 'node.attr1.attr2'.partitiion(‘.’)[-1]
· Split Method:- 'node.attr1.attr2'.split(‘.’, 1)[-1]
· Test:-
Iterate over 1000000 times.
Partition Method
1.98 1.96 1.97 1.97 1.98 1.95 1.95 1.95 1.95 1.96 1.96 sec |
Split Method
3.21 3.20 3.20 3.23 3.20 3.20 3.20 3.20 3.18 3.23 3.20 sec |
|
· Result:- partition method is 163% faster than split method.
· Remark:- this method can be extended for the fetching of simple attributes as well(eg. node.attr)
· Remark:- this method can be extended for the fetching of simple attributes as well(eg. node.attr)
HTML Comment Box is loading comments...