How to improve the performance when I set attribute for a huge amount of nodes?

How to improve the performance when I set attribute for a huge amount of nodes?

Anonymous
Not applicable
500 Views
2 Replies
Message 1 of 3

How to improve the performance when I set attribute for a huge amount of nodes?

Anonymous
Not applicable

 



Hi all,
I have the following function which comsumes a huge mount of time in my plugin:

def setAttr(node_list, visibility):
    for node in node_list:
        cmds.setAttr('%s.visibility'%node, visibility)

And I'm wondering how to improve the performance of this function.

I know that python and C++ have many ways to create multi-threads, and C++ code can also resort to OpenMP. But I'm not sure whether these methods are avaiable to Maya. I mean, I'm not sure whether Maya allows these methods to evaluate (e.g. set attribute or get attribute) parallelly.

Could anyone give me any suggetion? Both Python solution and C++ solution are OK, and Python solution is preferred.

 

Cheers
Yao

 

0 Likes
501 Views
2 Replies
Replies (2)
Message 2 of 3

chaneyx
Advocate
Advocate

In some cases the setting of the attribute may force a refresh of the model views. 

 

An easy way to test this is to run your script while there is no model view open. And if your attributes are shaders, make sure there is no shader view open.  The outliner , attributeEditor, hypergraph, etc. will be ok. 

 

How many nodes are you dealing with and what is their total polycount? 

0 Likes
Message 3 of 3

Anonymous
Not applicable

Thanks for your reply. 

The number of nodes may vary from thousands to millions, and the total number of polygons may vary from millions to billions. 

0 Likes