Keyframe Selection Code from Cineversity
-
Hi,
I'm trying to use this keyframe selection code from Cineversity..
I select an object but it prints nothing in the console. It also does not error out. You can see an illustration of the problem here:
https://www.dropbox.com/s/idwazt6lxg11mcl/c4d146_key_frame_selection.mp4?dl=0Should I change something in the code to accommodate possible changes in the Python API?
-
Hi,
works fine for me. But the code is missing import statements and a call to
main()
. Also the indentation is all messed up when you copy the code from their homepage. I just mangled the code through an autopeper, added import and invokedmain()
.On a side note: I am not sure if this is code you should learn from. This fine if you just want to get something done. For a learning site I find this unsuitable, but maybe I am to picky.
import c4d def GetKeyframeSelection(op): """ """ if not op or not op.KeyframeSelectionContent(): return None keySelection = [] desc = op.GetDescription(c4d.DESCFLAGS_DESC_0) for bc, paramid, groupid in desc: # print paramid # Handle Vectors - seems desc iterator only does top level if paramid[0].dtype == c4d.DTYPE_VECTOR: for i in xrange(c4d.VECTOR_X, c4d.VECTOR_Z+1): did = c4d.DescID( paramid[0], c4d.DescLevel(i, c4d.DTYPE_REAL, 0)) if op.FindKeyframeSelection(did): keySelection.append(did) # Handle top level DescIDs elif op.FindKeyframeSelection(paramid): keySelection.append(paramid) return keySelection def main(): """ """ keySelection = GetKeyframeSelection(op) if keySelection: print "*"*4, "Keyframe Select IDs", "*"*4 print keySelection if __name__ == "__main__": main()
Cheers
zipit -
@zipit
Thanks for the clarification.
Yea, I guess so but just learning as much as I can.Thanks again!