THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 23/07/2012 at 10:08, xxxxxxxx wrote:
Hi all,
I'm missing something to allow Python to register a scene change when I tell it to advance a frame with a call command (c4d.CallCommand(12414)). I am trying to find out when an object is 'Enabled' on a frame and then render that frame and saving the image with that object name. All is doing well, but when the frame advances, Python doesn't seem to register the changes in 'Enabled' states, which are animated on and off, frame to frame. I also wanted to capture which camera is active on a particular frame as well and run into the same problem of Python not picking up the updated frame state. All attempts to update Cinema per frame have failed so far. What do I do?
Also, while I'm asking questions, is there a better way to check to pause and see if the render is still rendering (I'm using c4d.CheckIsRunning), or is this the best way?
-Disclaimer: I'm new to programming, so the following code is rough, slow and could probably be broken up into functions, but that will come later when I am more comfortable with the language.
import c4d, math, string
from c4d import gui, utils
#Reverses order of render list, renames list items to be legal, and then renders with new names.
def main() :
c4d.CallCommand(12112) #Select All
c4d.CallCommand(100004748); #Unfold All
c4d.CallCommand(100004766) #Select all
Selected = doc.GetActiveObjects(1)
myDoc = c4d.documents.GetActiveDocument()
c4d.CallCommand(12501) #Goto Start Frame
startFrame = 0
hasRendered = 0
curFrame = doc.GetTime().GetFrame(doc.GetFps())
bc = c4d.BaseContainer()
shiftMod = 0
theFrame = 0
while theFrame < 99:
curFrame = doc.GetTime().GetFrame(doc.GetFps())
print "*****************************************"
print " THE CURRENT FRAME IS : " + str(curFrame)
print "*****************************************"
for ListOb in Selected:
curFrame = doc.GetTime().GetFrame(doc.GetFps())
theType = ListOb.GetTypeName()
xName = ListOb.GetName() #return the name of an object
print "The object type is: " + theType
if ListOb[c4d.ID_BASEOBJECT_GENERATOR_FLAG] == 0:
print xName + " is turned OFF"
if ListOb[c4d.ID_BASEOBJECT_GENERATOR_FLAG] == 1:
print xName + " is turned ON"
if theType != "XRef" or ListOb[c4d.ID_BASEOBJECT_GENERATOR_FLAG] != 1:
print "This is not an xref OR it is not turned on."
if theType == "XRef" and ListOb[c4d.ID_BASEOBJECT_GENERATOR_FLAG] == 1:
xName = ListOb.GetName() #return the name of an object
xName = xName[5:] + "_"
if xName[-4:] == ".c4d":
xName = xName[:-4]
xName = string.replace(xName, "/", "_")
xName = string.replace(xName, "(", "--")
xName = string.replace(xName, ")", "--")
xName = string.replace(xName, ".", "_")
xName = string.replace(xName, ",", "_")
print "--------------------------------------------------------"
print xName + "will render on this frame => " + str(curFrame)
print "--------------------------------------------------------"
path = "Users/david.cox/Desktop/testFolder/Accessory_catalog_Scene/"
rd = doc.GetActiveRenderData()
#path = rd[c4d.RDATA_PATH]
rd[c4d.RDATA_FRAMEFROM] = (c4d.BaseTime(startFrame + 1,30))
rd[c4d.RDATA_FRAMESEQUENCE] = (c4d.RDATA_FRAMESEQUENCE_CURRENTFRAME)
rd[c4d.RDATA_PATH] = path + xName
if hasRendered == 0:
c4d.CallCommand (12099) #calls the renderer
hasRendered = 1
isRend = c4d.CheckIsRunning(c4d.CHECKISRUNNING_EXTERNALRENDERING)
while isRend == 1:
isRend = c4d.CheckIsRunning(c4d.CHECKISRUNNING_EXTERNALRENDERING)
hasRendered = 0
if c4d.gui.GetInputState(c4d.BFM_INPUT_KEYBOARD,c4d.BFM_INPUT_CHANNEL,bc) :
if bc[c4d.BFM_INPUT_QUALIFIER] & c4d.QSHIFT:
shiftMod=1
print "Breaking out of loop"
break
if shiftMod==1:
break
#if hasRendered == 0:
if shiftMod==1:
break
c4d.CallCommand(12414) #Advance a frame
theFrame += 1
c4d.CallCommand(12501) #Goto Start Frame
c4d.EventAdd()
if __name__=='__main__':
main()