On 20/10/2014 at 00:25, xxxxxxxx wrote:
Hi Andreas,
I´ve already used the call button in the script.
But thank you for the good hint to check the main thread inside a plugin.
As I´m scripting the snippet yesterday between changing diapers and singing a lullaby.
Here a more efficient script without a list and more error checking.
@ Suda
Hope this helps.
import c4d
from c4d import gui
def GetNextObject(op) :
if op==None:
return None
if op.GetDown() :
return op.GetDown()
while not op.GetNext() and op.GetUp() :
op = op.GetUp()
return op.GetNext()
def IterateHierarchy(op) :
if op is None:
return
count = 0
while op:
count += 1
if op.GetType!=c4d.Opolygon:
dialog=gui.MessageDialog("A Polygon object for caching is needed",c4d.GEMB_OK)
if dialog== 1:
return
if op.GetTag(100004020)!= None:
ClothTag = op.GetTag(100004020)
c4d.CallButton(ClothTag, c4d.CLOTH_DO_CALCULATE )
op = GetNextObject(op)
return
def main() :
doc = c4d.documents.GetActiveDocument()
first = doc.GetFirstObject()
if first == None:return
IterateHierarchy(first)
if __name__=='__main__':
main()
Best wishes
Martin