How to seed up script with xform for vertexes?

How to seed up script with xform for vertexes?

Anonymous
Not applicable
676 Views
2 Replies
Message 1 of 3

How to seed up script with xform for vertexes?

Anonymous
Not applicable

Hello.

 

I have a simple function setKeyFramesForFacesAdvanced (see bellow). It calls for 5 objects for 30 frames (150 times). Each call takes ~40 seconds :-(.  Each object has 3000 - 5000 vertexes. Position of  vertexes (data array) calculated using special math in advance and finally I should setKeyFramesForFacesAdvanced for each object for each frame. I want to speed up the function.

My questions:
1) Is it possible to set vtx position for all vertexes simultaneously? (Currently it implemented as vertex by vertex and it called model recalculation each time) Some additional data - Position of vertexes are independent in my case. There is no influence to each other (like soft selection).
2) Is in possible to do setKeyframe for all  vertexes simultaneously or for while object? (I have tried to do cmds.setKeyframe( pObjectName, time=pTime ), but it does not work)

 

def setKeyFramesForFacesAdvanced(pObjectName, pTime, data):
for i in range (0, len(data)):
cmds.xform( pObjectName+".vtx[{0}]".format(i), t=data[i], worldSpace=True )
cmds.setKeyframe( pObjectName+".vtx[{0}]".format(i), time=pTime )

0 Likes
Accepted solutions (1)
677 Views
2 Replies
Replies (2)