I'm trying to add a codeline to a script which was originally written by Arttu Rautio. Basically I'm trying to activate or deactive child tag's proporties based on a frame (which makes the child object visible and active sequentially according to frame number). For example in the example I have attached I need to add Cloth Surface and Connect Object. But as I add Connect Object naturally It connects all children. This way I thought Stop Tag would work by enabling "Stop Generators" checkbox. All I need is to check/uncheck this box. Please check out the screenshot and code below. I really appreciate your support. Thank you.
# By Arttu Rautio (aturtur)
# https://aturtur.com/
# Libraries
import c4d
# Functions
def main():
try:
frame = doc[c4d.DOCUMENT_TIME].GetFrame(doc[c4d.DOCUMENT_FPS]) # Get current frame
obj = op.GetObject() # Get object
children = obj.GetChildren() # Get children
index = 0 # Initialize index variable
run = 0 # Initialize run variable
rev = op[c4d.ID_USERDATA,2] # User data: Reverse sequence
start = op[c4d.ID_USERDATA,3] # User data: Starting frame
holdf = op[c4d.ID_USERDATA,4] # User data: Hold first frame
holdl = op[c4d.ID_USERDATA,5] # User data: Hold last frame
manon = op[c4d.ID_USERDATA,7] # User data: Activate manual mode
manfr = op[c4d.ID_USERDATA,8] # User data: Set manual frame
if manon == False: # If manual mode is off
if rev == False: # If reverse mode is off
for child in children: # Loop through children
if frame == index+start: # If index maches with current frame
child[c4d.ID_BASEOBJECT_VISIBILITY_RENDER] = 2 # Default
child[c4d.ID_BASEOBJECT_VISIBILITY_EDITOR] = 2 # Default
child.Stop[c4d.STOPTAG_GENERATOR]= False
run = 1 # Sequence is running
else: # Otherwise
child[c4d.ID_BASEOBJECT_VISIBILITY_RENDER] = 1 # Off
child[c4d.ID_BASEOBJECT_VISIBILITY_EDITOR] = 1 # Off
child.Stop[c4d.STOPTAG_GENERATOR]= True
index = index + 1 # Increase index
else: # Otherwise
for child in reversed(children): # Loop through reversed children
if frame == index+start:
child[c4d.ID_BASEOBJECT_VISIBILITY_RENDER] = 2
child[c4d.ID_BASEOBJECT_VISIBILITY_EDITOR] = 2
run = 1
else: # Otherwise
child[c4d.ID_BASEOBJECT_VISIBILITY_RENDER] = 1
child[c4d.ID_BASEOBJECT_VISIBILITY_EDITOR] = 1
index = index + 1
if holdf == True and run == 0: # If hold start frame is on
if frame < len(children)+start:
if rev == True:
children[-1][c4d.ID_BASEOBJECT_VISIBILITY_RENDER] = 2
children[-1][c4d.ID_BASEOBJECT_VISIBILITY_EDITOR] = 2
else:
children[0][c4d.ID_BASEOBJECT_VISIBILITY_RENDER] = 2
children[0][c4d.ID_BASEOBJECT_VISIBILITY_EDITOR] = 2
if holdl == True and run == 0: # If hold last frame is on
if frame >= len(children)+start:
if rev == True:
children[0][c4d.ID_BASEOBJECT_VISIBILITY_RENDER] = 2
children[0][c4d.ID_BASEOBJECT_VISIBILITY_EDITOR] = 2
else:
children[-1][c4d.ID_BASEOBJECT_VISIBILITY_RENDER] = 2
children[-1][c4d.ID_BASEOBJECT_VISIBILITY_EDITOR] = 2
else: # Manual mode is on
for i, child in enumerate(children): # Loop through children
if i == manfr: # If index is same as custom frame
children[manfr][c4d.ID_BASEOBJECT_VISIBILITY_RENDER] = 2
children[manfr][c4d.ID_BASEOBJECT_VISIBILITY_EDITOR] = 2
else: # Otherwise
child[c4d.ID_BASEOBJECT_VISIBILITY_RENDER] = 1
child[c4d.ID_BASEOBJECT_VISIBILITY_EDITOR] = 1
except:
pass