def setMeshPosePosition(curObj, curTime, doCopy, curTrack, newObj, doc): c4d.documents.SetDocumentTime(doc, curTime) # set original Time c4d.DrawViews(c4d.DRAWFLAGS_FORCEFULLREDRAW | c4d.DRAWFLAGS_NO_THREAD | c4d.DRAWFLAGS_NO_REDUCTION | c4d.DRAWFLAGS_STATICBREAK) c4d.GeSyncMessage(c4d.EVMSG_TIMECHANGED) c4d.EventAdd(c4d.EVENT_ANIMATE) c4d.EventAdd(c4d.EVENT_FORCEREDRAW) c4d.DrawViews(c4d.DRAWFLAGS_FORCEFULLREDRAW) c4d.GeSyncMessage(c4d.EVMSG_ASYNCEDITORMOVE) newPositions = [] extraRemove = None if doCopy == True: doc.SetActiveObject(curObj, c4d.SELECTION_NEW) c4d.CallCommand(12233) curObj = curObj.GetNext() if curObj.GetType() != c4d.Opolygon: extraRemove = curObj curObj = curObj.GetDown() newPositions = getPositions(curObj, doc) thisCurve = curTrack.GetCurve() dictKey = thisCurve.AddKey(curTime) key = dictKey["key"] newObj.SetAllPoints(newPositions) newObj.Message(c4d.MSG_UPDATE) curTrack.FillKey(doc, newObj, key) if doCopy == True: curObj.Remove() if extraRemove is not None: extraRemove.Remove() return newPositions
def getMeshPosePosition(exportData, curObj, curTime, doCopy): c4d.documents.SetDocumentTime(exportData.doc, curTime) # set original Time c4d.DrawViews(c4d.DRAWFLAGS_FORCEFULLREDRAW | c4d.DRAWFLAGS_NO_THREAD | c4d.DRAWFLAGS_NO_REDUCTION | c4d.DRAWFLAGS_STATICBREAK) c4d.GeSyncMessage(c4d.EVMSG_TIMECHANGED) c4d.EventAdd(c4d.EVENT_ANIMATE) c4d.EventAdd(c4d.EVENT_FORCEREDRAW) c4d.DrawViews(c4d.DRAWFLAGS_FORCEFULLREDRAW) c4d.GeSyncMessage(c4d.EVMSG_ASYNCEDITORMOVE) newPositions = [] extraRemove = None if doCopy == True: exportData.doc.SetActiveObject(curObj, c4d.SELECTION_NEW) c4d.CallCommand(12233) curObj = curObj.GetNext() if curObj.GetType() != c4d.Opolygon: extraRemove = curObj curObj = curObj.GetDown() newPositions = getPositions(curObj, exportData) if doCopy == True: curObj.Remove() if extraRemove is not None: extraRemove.Remove() return newPositions
def resetAllObjectsAtBeginning(objList=None): for curObj in objList: #if curObj.GetTag(c4d.Tweights):# #c4d.documents.GetActiveDocument().SetActiveObject(curObj) #c4d.CallCommand(1019937) #c4d.DrawViews( c4d.DA_ONLY_ACTIVE_VIEW|c4d.DA_NO_THREAD|c4d.DA_NO_REDUCTION|c4d.DA_STATICBREAK ) #c4d.GeSyncMessage(c4d.EVMSG_TIMECHANGED) #c4d.documents.GetActiveDocument().SetTime(c4d.documents.GetActiveDocument().GetTime()) #c4d.EventAdd(c4d.EVENT_ANIMATE) if curObj.GetTag(c4d.Tposemorph):# reset morphtags all_tags=curObj.GetTags()#get all tags applied to object for morphtag in all_tags:#do for each tag: if morphtag.GetType()==c4d.Tposemorph:#do if the tag is a morphtag if morphtag.GetMode()==1:#do if the tag is in animation-mode: exportData.doc.SetTime(c4d.BaseTime(0, exportData.doc.GetFps())) c4d.DrawViews( c4d.DA_ONLY_ACTIVE_VIEW|c4d.DA_NO_THREAD|c4d.DA_NO_REDUCTION|c4d.DA_STATICBREAK ) c4d.GeSyncMessage(c4d.EVMSG_TIMECHANGED) exportData.doc.SetTime(exportData.doc.GetTime()) c4d.EventAdd(c4d.EVENT_ANIMATE) for track in morphtag.GetCTracks(): curve = track.GetCurve() if curve.GetKeyCount()==0: pass#print "skipped morphpose" if curve.GetKeyCount()>0: curve.GetKey(0).SetValue(curve,0.0) resetAllObjectsAtBeginning(curObj.GetChildren())
def _goToFrame(self, frame): time = c4d.BaseTime(frame, self.fps) self.doc.SetTime(time) self.doc.ExecutePasses( None, True, True, True, c4d.BUILDFLAGS_0) #try BUILDFLAGS_INTERNALRENDERER c4d.GeSyncMessage(c4d.EVMSG_TIMECHANGED) #update timeline
def main(): # Saves current time ctime = doc.GetTime() # Retrieves BaseTime of frame 5, 20 start = 5 end = 20 # Loops through the frames for frame in range(start, end + 1): # Sets the Status Bar c4d.StatusSetBar(100.0 * float(frame - start) / float(end - start)) # Changes the time of the document doc.SetTime(c4d.BaseTime(frame, doc.GetFps())) # Updates timeline c4d.GeSyncMessage(c4d.EVMSG_TIMECHANGED) # Redraws the viewport and regenerate the cache object c4d.DrawViews(c4d.DRAWFLAGS_ONLY_ACTIVE_VIEW | c4d.DRAWFLAGS_NO_THREAD | c4d.DRAWFLAGS_STATICBREAK) # Do the stuff for each frame here you may be interested in BaseDocument.Polygonize() print("Frame {0}".format(frame)) # Sets the time back to the original time. doc.SetTime(ctime) # Pushes an update event to Cinema 4D c4d.EventAdd(c4d.EVENT_ANIMATE) # Clears the Status Bar c4d.StatusClear()
def SetCurrentFrame(frame, doc): """ Changes editor's current frame to """ doc.SetTime(c4d.BaseTime(float(frame)/doc.GetFps())) # Set current time to given frame doc.ExecutePasses(None, True, True, True, 0) # Animate the current frame of the document c4d.GeSyncMessage(c4d.EVMSG_TIMECHANGED) # Send a synchronous event message that time has changed return
def main(): fps = doc.GetFps() #get fps number frame = 0 #set the start frame maxFrame = doc.GetLoopMaxTime().GetFrame(fps) #get all frame #For each frame while frame != maxFrame + 1: doc.SetTime(c4d.BaseTime(frame, fps)) #change time c4d.EventAdd() #Update scene c4d.DrawViews(c4d.DRAWFLAGS_FORCEFULLREDRAW) #ask to redraw the view c4d.GeSyncMessage(c4d.EVMSG_TIMECHANGED ) #send message to c4d we have change the time camera = doc.SearchObject("Camera.1") xform = camera.GetMg() pos = xform.Mul(c4d.Vector(0, 0, 0)) target = xform.Mul(c4d.Vector(0, 0, 1)) # pos = camera.GetAbsPos() # rotationmatrix = c4d.utils.HPBToMatrix(camera.GetAbsRot()) # target = pos + rotationmatrix.MulV(c4d.Vector(0,0,1)) print(str(pos)) print(str(target)) # rotate (0,0,1) by GetAbsRot to get a target point that the camera is pointing at. frame += 1 #define the next frame c4d.EventAdd() #Update scene
def updateViewer(self): """ update the 3d windows if any """ c4d.EventAdd() c4d.DrawViews(c4d.DRAWFLAGS_ONLY_ACTIVE_VIEW | c4d.DRAWFLAGS_NO_THREAD | c4d.DRAWFLAGS_NO_ANIMATION) c4d.GeSyncMessage(c4d.EVMSG_TIMECHANGED)
def walk_timeline(doc, start, end, update=True): ''' Iterate over each frame in the document from *start* to *end* and yield the current frame number while redrawing the viewport if *update* is True. The document time will be reset to the original time at the end of the iteration. .. code-block:: python for frame in iter_timeline(doc, 0, 100): pass # process current frame here :param doc: The :class:`c4d.BaseDocument` to iterate in. :param start: The start time, either :class:`c4d.BaseTime` or a frame number. :param end: The end time, either :class:`c4d.BaseTime` or a frame number. :param update: If True, the viewport is updated with :func:`update_viewport` and :func:`c4d.GeSyncMessage` before the current frame number is passed to the caller. This is usually desired. ''' fps = doc.GetFps() time = doc.GetTime() if isinstance(start, c4d.BaseTime): start = start.GetFrame(fps) if isinstance(end, c4d.BaseTime): end = end.GetFrame(fps) for frame in xrange(start, end + 1): doc.SetTime(c4d.BaseTime(frame, fps)) if update: update_viewport() c4d.GeSyncMessage(c4d.EVMSG_TIMECHANGED) yield frame doc.SetTime(time) if update: update_viewport() c4d.GeSyncMessage(c4d.EVMSG_TIMECHANGED)
def walk_timeline(doc, start, end, update=True): ''' Iterate over each frame in the document from *start* to *end* and yield the current frame number while redrawing the viewport if *update* is True. The document time will be reset to the original time at the end of the iteration. ```python for frame in iter_timeline(doc, 0, 100): pass # process current frame here ``` doc (c4d.BaseDocument): start (c4d.BaseTime, int): The start time, either as time or frame number. end (c4d.BaseTime, int): The end time, either as time or frame number. update (bool): If #True, the viewport is updated with #update_viewport() and #c4d.GeSyncMessage before the current frame number is passed to the caller. This is usually desired. ''' fps = doc.GetFps() time = doc.GetTime() if isinstance(start, c4d.BaseTime): start = start.GetFrame(fps) if isinstance(end, c4d.BaseTime): end = end.GetFrame(fps) for frame in xrange(start, end + 1): doc.SetTime(c4d.BaseTime(frame, fps)) if update: update_viewport() c4d.GeSyncMessage(c4d.EVMSG_TIMECHANGED) yield frame doc.SetTime(time) if update: update_viewport() c4d.GeSyncMessage(c4d.EVMSG_TIMECHANGED)
def buildSkeletonPose(exportData,curObj,curTime): newAWDWrapperBlock=classesAWDBlocks.WrapperBlock(None,"",0) exportData.allAWDBlocks.append(newAWDWrapperBlock) newAWDBlock=classesAWDBlocks.SkeletonPoseBlock(exportData.idCounter,0,curObj.GetTag(1028938)[1011]) exportData.idCounter+=1 newAWDBlock.name=curObj.GetTag(1028938)[1011] c4d.documents.SetDocumentTime(exportData.doc, curTime)# set original Time c4d.DrawViews( c4d.DRAWFLAGS_FORCEFULLREDRAW|c4d.DRAWFLAGS_NO_THREAD|c4d.DRAWFLAGS_NO_REDUCTION|c4d.DRAWFLAGS_STATICBREAK ) c4d.GeSyncMessage(c4d.EVMSG_TIMECHANGED) c4d.EventAdd(c4d.EVENT_ANIMATE) c4d.EventAdd(c4d.EVENT_FORCEREDRAW) c4d.DrawViews( c4d.DRAWFLAGS_FORCEFULLREDRAW) c4d.GeSyncMessage(c4d.EVMSG_ASYNCEDITORMOVE) newAWDBlock.transformations=[] buildJointTransform([curObj],newAWDBlock.transformations,exportData,True) # recursive function to get all Joints as JointBlocks newAWDWrapperBlock.data=newAWDBlock newAWDWrapperBlock.blockType=102 newAWDWrapperBlock.tagForExport=True return newAWDWrapperBlock
def printErrors(mainDialog,exportData): if len(exportData.AWDerrorObjects)>0: maindialogHelpers.enableAll(mainDialog,True) newMessage=c4d.plugins.GeLoadString(ids.ERRORMESSAGE)+"\n" for errorMessage in exportData.AWDerrorObjects: newMessage+=c4d.plugins.GeLoadString(errorMessage.errorID) if errorMessage.errorData!=None: newMessage+="\n\n"+str(c4d.plugins.GeLoadString(ids.ERRORMESSAGEOBJ))+" = "+str(errorMessage.errorData) c4d.gui.MessageDialog(newMessage) exportData=None if mainDialog.GetBool(ids.CBOX_CLOSEAFTEREXPORT) == True: exportData=None c4d.DrawViews( c4d.DA_ONLY_ACTIVE_VIEW|c4d.DA_NO_THREAD|c4d.DA_NO_REDUCTION|c4d.DA_STATICBREAK ) c4d.GeSyncMessage(c4d.EVMSG_TIMECHANGED) c4d.EventAdd(c4d.EVENT_ANIMATE) mainDialog.Close() c4d.DrawViews( c4d.DA_ONLY_ACTIVE_VIEW|c4d.DA_NO_THREAD|c4d.DA_NO_REDUCTION|c4d.DA_STATICBREAK ) c4d.GeSyncMessage(c4d.EVMSG_TIMECHANGED) c4d.EventAdd(c4d.EVENT_ANIMATE) exportData=None return False return True
def main(): doc = c4d.documents.GetActiveDocument() fps = doc[ c4d.DOCUMENT_FPS ] minTime = doc[ c4d.DOCUMENT_MINTIME ].GetFrame( fps ) maxTime = doc[ c4d.DOCUMENT_MAXTIME ].GetFrame( fps ) f = 0 for f in range( minTime, maxTime ): doc.SetTime( c4d.BaseTime( f, fps ) ) c4d.DrawViews( c4d.DA_ONLY_ACTIVE_VIEW|c4d.DA_NO_THREAD|c4d.DA_NO_REDUCTION|c4d.DA_STATICBREAK ) c4d.GeSyncMessage( c4d.EVMSG_TIMECHANGED ) c4d.EventAdd( c4d.EVENT_ANIMATE ) frame( f ) if escPressed(): break gui.MessageDialog( "%i - %i frames processed." % (minTime, f) )
def main(): # for each frame render the associated 3DS file. # The view and animation must already be defined # through the GUI. doc = c4d.documents.GetActiveDocument() fps = doc.GetFps() start = doc.GetMinTime().GetFrame(fps) until = doc.GetMaxTime().GetFrame(fps) # For each frame we save the associated 3DS file. for i in xrange(start, until): # Construct new name tmp_name = [] tmp_name.append('/Users/Robin/Desktop/Scene_3ds/') tmp_name.append('scene.{0:04d}'.format(i)) tmp_name.append('.3ds') name = ''.join(tmp_name) print 'Export : %r' % name # Move to frame doc.SetTime(c4d.BaseTime(i, fps)) # Update GUI c4d.DrawViews(c4d.DRAWFLAGS_ONLY_ACTIVE_VIEW | c4d.DRAWFLAGS_NO_THREAD | c4d.DRAWFLAGS_NO_REDUCTION | c4d.DRAWFLAGS_STATICBREAK) # Update timeline c4d.GeSyncMessage(c4d.EVMSG_TIMECHANGED) # Save document e = c4d.documents.SaveDocument(doc=doc, name=name, saveflags=c4d.SAVEDOCUMENTFLAGS_0, format=c4d.FORMAT_3DSEXPORT) if not e: gui.MessageDialog("Unable to export frame %r" % i) return else: print "Frame %r saved" % i
def TransferAnim(self): #Comparison list for Lumiere Rig Template ctrlCompList = { 'hip_CTRL_FK_Dummy' : 'hip_CTRL', 'r_shldr_CTRL_FK_Dummy' : 'r_shldr_CTRL', 'l_shldr_CTRL_FK_Dummy' : 'l_shldr_CTRL', 'r_elbow_CTRL_FK_Dummy' : 'r_elbow_CTRL', 'l_elbow_CTRL_FK_Dummy' : 'l_elbow_CTRL', 'l_hand_CTRL_FK_Dummy' : 'l_hand_CTRL', 'r_hand_CTRL_FK_Dummy' : 'r_hand_CTRL', 'r_Thumb_CTRL_FK_Dummy' : 'r_Thumb_CTRL', 'l_Thumb_CTRL_FK_Dummy' : 'l_Thumb_CTRL', 'r_Pinky_CTRL_FK_Dummy' : 'r_hand_CTRL', 'l_Pinky_CTRL_FK_Dummy' : 'r_hand_CTRL', 'r_Ring_CTRL_FK_Dummy' : 'r_hand_CTRL', 'l_Ring_CTRL_FK_Dummy' : 'r_hand_CTRL' 'r_Mid_CTRL_FK_Dummy' : 'r_hand_CTRL', 'l_Mid_CTRL_FK_Dummy' : 'r_hand_CTRL', 'r_Index_CTRL_FK_Dummy' : 'r_hand_CTRL', 'l_Index_CTRL_FK_Dummy' : 'r_hand_CTRL', 'chest_CTRL_FK_Dummy' : 'chest_CTRL', 'neck_CTRL_FK_Dummy' : 'neck_CTRL', 'head_CTRL_FK_Dummy' : 'head_CTRL', 'r_toe_CTRL_FK_Dummy' : 'r_toe_CTRL', 'l_toe_CTRL_FK_Dummy' : 'l_toe_CTRL', 'r_ball_CTRL_FK_Dummy' : 'r_ball_CTRL', 'l_ball_CTRL_FK_Dummy' : 'l_ball_CTRL', 'r_Knee_CTRL_FK_Dummy' : 'r_Knee_CTRL', 'l_Knee_CTRL_FK_Dummy' : 'l_Knee_CTRL', 'r_Foot_CTRL_FK_Dummy' : 'r_Foot_CTRL', 'l_Foot_CTRL_FK_Dummy' : 'l_Foot_CTRL', 'r_heel_CTRL_FK_Dummy' : 'r_heel_CTRL', 'l_heel_CTRL_FK_Dummy' : 'l_heel_CTRL', 'COG_CTRL_FK_Dummy' : 'COG_CTRL' } # Get active doc doc = c4d.documents.GetActiveDocument() # Get project current start and end frames startFrameValue = int(doc.GetMinTime().GetFrame(doc.GetFps())) endFrameValue = int(doc.GetMaxTime().GetFrame(doc.GetFps())) #Get the soucre and target children, we want to iterate through these lists in order to pull #out the exact Nulls we need to work with, we also need the counts for out for loops sourceChildren = self.sourceLink.GetLink().GetChildren() targetChildren = self.targetLink.GetLink().GetChildren() sourceChildCnt = len(sourceChildren) targetChildCnt = len(targetChildren) # deslect all objects, the script set keys on the selected object, so we only want objects active # that we make active c4d.CallCommand(100004767) # loop through the animation as defined by C4D's start and end times in this document, and record a # key for every frame for frame in range(startFrameValue, endFrameValue): # Set the docs current time to the correct frame so we can capture the key doc.SetTime(c4d.BaseTime(float(frame)/doc.GetFps())) doc.ExecutePasses(None, True, True, True, 0); c4d.GeSyncMessage(c4d.EVMSG_TIMECHANGED) # loop through the source's children, once we find one of our dummy Nulls we need to then loop # through the target children for the coresponding IK controller, finally well animate the power # slider and record the dummy's global positions and rotations into the IK as keys for i in range(0, sourceChildCnt): if(sourceChildren[i].GetName() in ctrlCompList): sourceObj = sourceChildren[i] for j in range(0, targetChildCnt): if(targetChildren[j].GetName() == ctrlCompList[sourceObj.GetName()]): targetObj = targetChildren[j] targetObj.SetBit(c4d.BIT_ACTIVE) #Set target Null active so it can receive keys # get the world postion and rotation of the source dummy Null and apply it the the target IK/FK CTRL #targetObj.SetAbsPos(sourceObj.GetAbsPos()) #targetObj.SetAbsRot(sourceObj.GetAbsRot()) targetObj.SetMg(sourceObj.GetMg()) c4d.CallCommand(12410) #Records a key on active object targetObj.DelBit(c4d.BIT_ACTIVE) break c4d.EventAdd()
def main(): coldata1 = "F:/ipcContentChapel001.csv" doc = c4d.documents.GetActiveDocument() ctime = doc.GetTime() # Save current time # Get FPS and minimum + maximum frames fps = doc.GetFps() start = doc.GetMinTime().GetFrame(fps) end = doc.GetMaxTime().GetFrame(fps) op = doc.SearchObject('sunmatrix') #search for object in c4d to store data op2 = doc.SearchObject( 'skymatrix') #search for object in c4d to store data op3 = doc.SearchObject('creepyman') op4 = doc.SearchObject('ledsSoloMorning') op5 = doc.SearchObject('ledsSoloEvening') with open(coldata1, 'wb') as f: #for frame in xrange(start,end+1): frame = 0 #print c4d.BaseTime(frame,fps) while c4d.BaseTime(frame, fps) < doc.GetMaxTime(): bt = c4d.BaseTime(frame, fps) #current frame,frame rate c4d.documents.SetDocumentTime(doc, bt) #print "Document time : ", doc.GetTime().GetFrame(fps) c4d.GeSyncMessage( c4d.EVMSG_TIMECHANGED ) # make the timeline, timeslider etc. do an instant redraw.) c4d.EventAdd(c4d.EVENT_ANIMATE) md = mo.GeGetMoData(op) md2 = mo.GeGetMoData(op2) md3 = mo.GeGetMoData(op3) md4 = mo.GeGetMoData(op4) md5 = mo.GeGetMoData(op5) if md == None and md2 == None and md3 == None: return False cnt = md.GetCount() marr = md.GetArray(c4d.MODATA_CLONE) carr = md.GetArray(c4d.MODATA_COLOR) cnt2 = md2.GetCount() marr2 = md2.GetArray(c4d.MODATA_CLONE) carr2 = md2.GetArray(c4d.MODATA_COLOR) cnt3 = md3.GetCount() marr3 = md3.GetArray(c4d.MODATA_CLONE) carr3 = md3.GetArray(c4d.MODATA_COLOR) cnt4 = md4.GetCount() marr4 = md4.GetArray(c4d.MODATA_CLONE) carr4 = md4.GetArray(c4d.MODATA_COLOR) cnt5 = md5.GetCount() marr5 = md5.GetArray(c4d.MODATA_CLONE) carr5 = md5.GetArray(c4d.MODATA_COLOR) c4d.DrawViews() node_count = 0 #count node allcol = [] for c, d, e, j, k in zip(carr, carr2, carr3, carr4, carr5): cx = c * 255 #multiply colour vals by 255 to get RGB r = int(cx[0]) g = int(cx[1]) b = int(cx[2]) w = int((r + g + b) / 10) if (r >= 254): r = 254 if (g >= 254): g = 254 if (b >= 254): b = 254 if (w >= 254): w = 254 dx = d * 255 #multiply colour vals by 255 to get RGB r2 = int(dx[0]) g2 = int(dx[1]) b2 = int(dx[2]) w2 = int((r2 + g2 + b2) / 10) if (r2 >= 254): r2 = 254 if (g2 >= 254): g2 = 254 if (b2 >= 254): b2 = 254 if (w2 >= 254): w2 = 254 ex = e * 255 #multiply colour vals by 255 to get RGB r3 = int(ex[0]) g3 = int(ex[1]) b3 = int(ex[2]) w3 = int((r3 + g3 + b3) / 10) if (r3 >= 254): r3 = 254 if (g3 >= 254): g3 = 25 if (b3 >= 254): b3 = 254 if (w3 >= 254): w3 = 254 jx = j * 255 #multiply colour vals by 255 to get RGB r4 = int(jx[0]) g4 = int(jx[1]) b4 = int(jx[2]) w4 = int((r4 + g4 + b4) / 10) if (r4 >= 254): r4 = 254 if (g4 >= 254): g4 = 254 if (b4 >= 254): b4 = 254 if (w4 >= 254): w4 = 254 kx = k * 255 #multiply colour vals by 255 to get RGB r5 = int(kx[0]) g5 = int(kx[1]) b5 = int(kx[2]) w5 = int((r5 + g5 + b5) / 10) if (r5 >= 254): r5 = 254 if (g5 >= 254): g5 = 254 if (b5 >= 254): b5 = 254 if (w5 >= 254): w5 = 254 allcol.append(r) allcol.append(r2) allcol.append(r3) allcol.append(r4) allcol.append(r5) allcol.append(g) allcol.append(g2) allcol.append(g3) allcol.append(g4) allcol.append(g5) allcol.append(b) allcol.append(b2) allcol.append(b3) allcol.append(b4) allcol.append(b5) allcol.append(w) allcol.append(w2) allcol.append(w3) allcol.append(w4) allcol.append(w5) #append the led value for morning sun here #append the led value for the evening sun here newSplitList = [ allcol[i:i + 1200] for i in xrange(0, len(allcol), 1200) ] #60 pixels x 4 (rgbw) = 240 values per frame for lst2 in newSplitList: for i, item in enumerate(lst2): col_str = str( item ) #must be string in csv clamp stops negatives from occuring export as int #write string of col vals to csv f.write(col_str) if (i == len(lst2) - 1): f.write('\n') else: f.write(',') #separate values with comma in csv file #see node and colour for each frame in c4d console #print "Node ID : ", node_count, " || Writing value : ", col255 node_count += 1 #plus 2268 #print "Frame " , frame #gen.Message(c4d.MSG_UPDATE) #op.Message(c4d.MSG_UPDATE) c4d.EventAdd( c4d.EVENT_ANIMATE ) #Adds a global event to Cinema 4D’s event queue. Results in a CoreMessage() message. frame += 1 f.close()
def main(): global path, rangeStart, rangeEnd doc = documents.GetActiveDocument() docFPS = doc[c4d.DOCUMENT_FPS] d_print("Document FPS: " + str(docFPS)) try: cam = doc.GetSelection()[0] if not cam.GetType() == 5103: gui.MessageDialog("Please select a Camera to export") return except IndexError: gui.MessageDialog("Please select a Camera to export") return camTracks = [] for i in range(903, 905): for j in range(1000, 1003): track = cam.FindCTrack( c4d.DescID(c4d.DescLevel(i), c4d.DescLevel(j))) camTracks.append(track) rangeStart = camTracks[0].GetCurve().GetKey(0).GetTime().GetFrame(docFPS) rangeEnd = camTracks[0].GetCurve().GetKey( camTracks[0].GetCurve().GetKeyCount() - 1).GetTime().GetFrame(docFPS) dlg = Dialog() dlg.startFrame = rangeStart dlg.endFrame = rangeEnd dlg.Open(c4d.DLG_TYPE_MODAL_RESIZEABLE, defaultw=500) if not dlg.didPressOK: return keyFrameInterval = dlg.keyFrameInterval timeOffsetInFrames = dlg.timeOffsetInFrames sceneScale = dlg.sceneScale frameSpaceInS = dlg.frameSpaceInS startFrame = dlg.startFrame endFrame = dlg.endFrame targetFPS = dlg.targetFPS d_print("Keyframe Interval: " + str(keyFrameInterval)) d_print("Time Offset: " + str(timeOffsetInFrames)) d_print("Scene Scale: " + str(sceneScale)) d_print("Frame Space: " + str(frameSpaceInS)) d_print("Range Start: " + str(rangeStart)) d_print("Range End: " + str(rangeEnd)) d_print("Target FPS: " + str(targetFPS)) path = storage.LoadDialog(flags=2) if not path: print "No path found" return if not os.path.exists(path + '/fullsequence_empty.xml'): os.rename(path + '/fullsequence.xml', path + '/fullsequence_empty.xml') f = open(path + '/fullsequence_empty.xml', 'r') xmlText = f.read() f.close() split1 = string.rfind(xmlText, "</Syncronorm_ShowSequence_V1.0>") split2 = string.rfind(xmlText, "</blocks>") string1 = xmlText[:split2 - 1] string2 = xmlText[split2:split1 - 1] string3 = xmlText[split1:] insertString1 = "" insertString2 = "<SceneList>" for frame in range(startFrame, endFrame + keyFrameInterval, keyFrameInterval): d_print("\n\n---------- Frame: " + str(frame) + ' ----------') ID = str(uuid.uuid4()) startTime = (frame / targetFPS) + (timeOffsetInFrames / targetFPS) - ( keyFrameInterval / targetFPS) + (1 / docFPS) startTime = string.replace(str(startTime), ".", ",") d_print("Start Time: " + str(startTime)) length = (keyFrameInterval / targetFPS) - frameSpaceInS length = string.replace(str(length), ".", ",") d_print("Length: " + str(length)) doc.SetTime(c4d.BaseTime(frame, docFPS)) c4d.DrawViews(c4d.DA_ONLY_ACTIVE_VIEW | c4d.DA_NO_THREAD | c4d.DA_NO_REDUCTION | c4d.DA_STATICBREAK) c4d.GeSyncMessage(c4d.EVMSG_TIMECHANGED) posX = cam.GetMg().off.x * sceneScale posY = cam.GetMg().off.y * sceneScale posZ = -cam.GetMg().off.z * sceneScale rotX = -MatrixToHPB(cam.GetMg()).x * 180 / math.pi rotY = -MatrixToHPB(cam.GetMg()).y * 180 / math.pi rotZ = MatrixToHPB(cam.GetMg()).z * 180 / math.pi if (rotX <= -180): rotX = rotX + 360 if (rotX >= 180): rotX = rotX - 360 if (rotY <= -180): rotY = rotY + 360 if (rotY >= 180): rotY = rotY - 360 if (rotZ <= -180): rotZ = rotZ + 360 if (rotZ >= 180): rotZ = rotZ - 360 # posX = round(posX, 6) # posY = round(posY, 6) # posZ = round(posZ, 6) rotX = round(rotX, 3) rotY = round(rotY, 3) rotZ = round(rotZ, 3) posX = string.replace(str(posX), ".", ",") posY = string.replace(str(posY), ".", ",") posZ = string.replace(str(posZ), ".", ",") rotX = string.replace(str(rotX), ".", ",") rotY = string.replace(str(rotY), ".", ",") rotZ = string.replace(str(rotZ), ".", ",") d_print(posX) d_print(posY) d_print(posZ) d_print(rotX) d_print(rotY) d_print(rotZ) insertString1 = ( insertString1 + '\n<block Name="CamPos" StartTime="' + startTime + '" Lenght="' + length + '" FadeInTime="' + length + '" FadeOutTime="0" DelayInTime="0" DelayOutTime="0" BeatsPerMinute="120" UseACD="False" ACD_InDelay="0" ACD_InFade="0" ACD_OutDelay="0" ACD_OutFade="0" Mute="False" Freeze="False" Tracking="True" EffectSpeedOffset="0" MultiSceneGUID="' + ID + '" CueListGUID="" FadeCenter="True" FadeAmplitude="True" FadePhase="True" FadeRpM="False" UsedCenter="True" UsedAmplitude="True" UsedPhase="True" UsedRpM="True" InFadeRate="100" OutFadeRate="100" FadeType="0" DelayType="0" LightColor="-1">\n' + ' <LightColorX red="255" green="255" blue="255" amber="0" white="0" intensity="255" CellX="0" CellY="0"></LightColorX>\n' + '</block>') insertString2 = ( insertString2 + '<scene GroupGUID="" GUID="' + ID + '" AggTypeGUID="" InDelayTime="0" InFadeTime="0" Name="CamPos" OutDelayTime="0" OutFadeTime="0" IsUniqueBlockScene="False" UsedSplines="True">\n' + ' <Items>\n' + ' <Item UID="65500" PatternGUID="" Amplitude="0" Center="0" EffectGUID="" InDelayPoint="0" InFadePoint="100" Offset="0" OutDelayPoint="0" OutFadePoint="100" MaxPhase="0" Phase="' + posX + '" RpM="0" NumWaves="1" GoOut="0" CutAfter="1" SelectionIndex="0" Direction="0" TogleWinkelLeft="0" TogleWinkelRight="360" VisibleWaves="1" BNC_StartReverse="False" ValueOffset="0" FadeCenter="True" FadeAmplitude="True" FadePhase="True" FadeRpM="False" UsedCenter="True" UsedAmplitude="True" UsedPhase="True" UsedRpM="True" InFadeRate="100" OutFadeRate="100" FadeType="0" DelayType="0"></Item>\n' + ' <Item UID="65504" PatternGUID="" Amplitude="0" Center="0" EffectGUID="" InDelayPoint="0" InFadePoint="100" Offset="0" OutDelayPoint="0" OutFadePoint="100" MaxPhase="0" Phase="' + posY + '" RpM="0" NumWaves="1" GoOut="0" CutAfter="1" SelectionIndex="0" Direction="0" TogleWinkelLeft="0" TogleWinkelRight="360" VisibleWaves="1" BNC_StartReverse="False" ValueOffset="0" FadeCenter="True" FadeAmplitude="True" FadePhase="True" FadeRpM="False" UsedCenter="True" UsedAmplitude="True" UsedPhase="True" UsedRpM="True" InFadeRate="100" OutFadeRate="100" FadeType="0" DelayType="0"></Item>\n' + ' <Item UID="65508" PatternGUID="" Amplitude="0" Center="0" EffectGUID="" InDelayPoint="0" InFadePoint="100" Offset="0" OutDelayPoint="0" OutFadePoint="100" MaxPhase="0" Phase="' + posZ + '" RpM="0" NumWaves="1" GoOut="0" CutAfter="1" SelectionIndex="0" Direction="0" TogleWinkelLeft="0" TogleWinkelRight="360" VisibleWaves="1" BNC_StartReverse="False" ValueOffset="0" FadeCenter="True" FadeAmplitude="True" FadePhase="True" FadeRpM="False" UsedCenter="True" UsedAmplitude="True" UsedPhase="True" UsedRpM="True" InFadeRate="100" OutFadeRate="100" FadeType="0" DelayType="0"></Item>\n' + ' <Item UID="65512" PatternGUID="" Amplitude="0" Center="0" EffectGUID="" InDelayPoint="0" InFadePoint="100" Offset="0" OutDelayPoint="0" OutFadePoint="100" MaxPhase="0" Phase="' + rotX + '" RpM="0" NumWaves="1" GoOut="0" CutAfter="1" SelectionIndex="0" Direction="0" TogleWinkelLeft="0" TogleWinkelRight="360" VisibleWaves="1" BNC_StartReverse="False" ValueOffset="0" FadeCenter="True" FadeAmplitude="True" FadePhase="True" FadeRpM="False" UsedCenter="True" UsedAmplitude="True" UsedPhase="True" UsedRpM="True" InFadeRate="100" OutFadeRate="100" FadeType="0" DelayType="0"></Item>\n' + ' <Item UID="65516" PatternGUID="" Amplitude="0" Center="0" EffectGUID="" InDelayPoint="0" InFadePoint="100" Offset="0" OutDelayPoint="0" OutFadePoint="100" MaxPhase="0" Phase="' + rotY + '" RpM="0" NumWaves="1" GoOut="0" CutAfter="1" SelectionIndex="0" Direction="0" TogleWinkelLeft="0" TogleWinkelRight="360" VisibleWaves="1" BNC_StartReverse="False" ValueOffset="0" FadeCenter="True" FadeAmplitude="True" FadePhase="True" FadeRpM="False" UsedCenter="True" UsedAmplitude="True" UsedPhase="True" UsedRpM="True" InFadeRate="100" OutFadeRate="100" FadeType="0" DelayType="0"></Item>\n' + ' <Item UID="65520" PatternGUID="" Amplitude="0" Center="0" EffectGUID="" InDelayPoint="0" InFadePoint="100" Offset="0" OutDelayPoint="0" OutFadePoint="100" MaxPhase="0" Phase="' + rotZ + '" RpM="0" NumWaves="1" GoOut="0" CutAfter="1" SelectionIndex="0" Direction="0" TogleWinkelLeft="0" TogleWinkelRight="360" VisibleWaves="1" BNC_StartReverse="False" ValueOffset="0" FadeCenter="True" FadeAmplitude="True" FadePhase="True" FadeRpM="False" UsedCenter="True" UsedAmplitude="True" UsedPhase="True" UsedRpM="True" InFadeRate="100" OutFadeRate="100" FadeType="0" DelayType="0"></Item>\n' + ' </Items>\n' + ' <WayPoints PointData=""></WayPoints>\n' + '</scene>\n') insertString1 = insertString1 + "" insertString2 = insertString2 + "</SceneList>" f = open(path + '/fullsequence.xml', 'w') f.write(string1 + insertString1 + string2 + insertString2 + string3) f.close() gui.MessageDialog("Camera Export Successful")
def GetMesh(code): # goto 0 doc.SetTime(c4d.BaseTime(0, fps)) c4d.DrawViews(c4d.DA_ONLY_ACTIVE_VIEW | c4d.DA_NO_THREAD | c4d.DA_NO_REDUCTION | c4d.DA_STATICBREAK) c4d.GeSyncMessage(c4d.EVMSG_TIMECHANGED) doc.SetTime(doc.GetTime()) c4d.EventAdd(c4d.EVENT_ANIMATE) SendModelingCommand(command=c4d.MCOMMAND_REVERSENORMALS, list=[op], mode=c4d.MODIFY_ALL, bc=c4d.BaseContainer(), doc=doc) verts = op.GetAllPoints() for v in verts: code += '\tv( %.6f, %.6f, %.6f );\n' % (v.x, -v.y, v.z) code += '\n' ncount = 0 uvcount = 0 faces = op.GetAllPolygons() normals = op.CreatePhongNormals() ndirection = 1 hasUV = False for tag in op.GetTags(): if tag.GetName() == "UVW": uvw = tag hasUV = True for f in faces: if (f.d == f.c): if (normals): code += '\tf3( %d, %d, %d, %.6f, %.6f, %.6f );\n' % ( f.a, f.b, f.c, normals[ncount].x * ndirection, normals[ncount].y * ndirection, normals[ncount].z * ndirection) else: code += '\tf3( %d, %d, %d );\n' % (f.a, f.b, f.c) else: if (normals): code += '\tf4( %d, %d, %d, %d, %.6f, %.6f, %.6f );\n' % ( f.a, f.b, f.c, f.d, normals[ncount].x * ndirection, normals[ncount].y * ndirection, normals[ncount].z * ndirection) else: code += '\tf4( %d, %d, %d, %d );\n' % (f.a, f.b, f.c, f.d) if hasUV: uv = uvw.GetSlow(uvcount) # uvs += '[Vector('+str(uv[0].x)+','+str(1.0-uv[0].y)+'),Vector('+str(uv[1].x)+','+str(1.0-uv[1].y)+'),Vector('+str(uv[2].x)+','+str(1.0-uv[2].y)+')],' if len(uv) == 4: # {'a': Vector(1, 1, 0), 'c': Vector(0, 0, 0), 'b': Vector(1, 0, 0), 'd': Vector(0, 1, 0)} code += '\tuv( %.6f, %.6f, %.6f, %.6f, %.6f, %.6f, %.6f, %.6f);\n' % ( uv['a'].x, uv['a'].y, uv['b'].x, uv['b'].y, uv['b'].x, uv['b'].y, uv['c'].x, uv['c'].y) else: code += '\tuv( %.6f, %.6f, %.6f, %.6f, %.6f, %.6f);\n' % ( uv['a'].x, uv['a'].y, uv['b'].x, uv['b'].y, uv['c'].x, uv['c'].y) ncount += 1 uvcount += 1 code += '\n\tthis.computeCentroids();\n\tthis.computeNormals(true);\n' #selection color code += '\n\tscope.colors = {};\n' code += '\tscope.selections = {};\n' selName = '' for tag in op.GetTags(): if (tag.GetType() == 5616): #texture tag material = tag.GetMaterial() color = material[c4d.MATERIAL_COLOR_COLOR] tag.SetBit(c4d.BIT_ACTIVE) selName = clean(tag[c4d.TEXTURETAG_RESTRICTION]) if len(selName) == 0: print "*** WARNING! *** Missing selection name for material: " + material.GetName( ) code += '\tscope.colors["' + selName + '"] = ' + str( RGBToHTMLColor( (color.x * 255, color.y * 255, color.z * 255))) + ';\n' if tag.GetType() == 5673: #selection tag print 'selection: ' + tag.GetName() print 'selection object: ' + tag sel = tag.GetSelection() selName = clean(tag.GetName()) ids = sel.GetAll(op.GetPointCount()) indices = [i for i, e in enumerate(ids) if e != 0] code += '\tscope.selections["' + selName + '"] = ' + str( indices) + ';\n' code += '\n\tscope.autoColor = function(){\n' code += '\t\tfor(var s in this.selections){\n' code += '\t\t\tfor(var i = 0 ; i < this.selections[s].length; i++) this.faces[this.selections[s][i]].material = [new THREE.MeshBasicMaterial({color:this.colors[s]})];\n' code += '\t\t}\n\t}\n' # model position, rotation, scale rotation x,y,z = H,P,B => three.js x,y,z is P,H,B => y,x,z p = op.GetPos() r = op.GetRot() s = op.GetScale() code += '\n\tscope.getPosition = function(){\treturn new THREE.Vector3' + str( (p.x, p.y, p.z)) + ';\t}\n' code += '\n\tscope.getRotation = function(){\treturn new THREE.Vector3' + str( (r.y, r.x, r.z)) + ';\t}\n' code += '\n\tscope.getScale = function(){\treturn new THREE.Vector3' + str( (s.x, s.y, s.z)) + ';\t}\n' code += '\n' code += '\tfunction v( x, y, z ) {\n\n' code += '\t\tscope.vertices.push( new THREE.Vertex( new THREE.Vector3( x, y, z ) ) );\n\n' code += '\t}\n\n' code += '\tfunction f3( a, b, c, nx, ny, nz ) {\n\n' code += '\t\tscope.faces.push( new THREE.Face3( a, b, c, nx && ny && nz ? new THREE.Vector3( nx, ny, nz ) : null ) );\n\n' code += '\t}\n\n' code += '\tfunction f4( a, b, c, d, nx, ny, nz ) {\n\n' code += '\t\tscope.faces.push( new THREE.Face4( a, b, c, d, nx && ny && nz ? new THREE.Vector3( nx, ny, nz ) : null ) );\n\n' code += '\t}\n\n' code += '\tfunction uv( u1, v1, u2, v2, u3, v3, u4, v4 ) {\n\n' code += '\t\tvar uv = [];\n' code += '\t\tuv.push( new THREE.UV( u1, v1 ) );\n' code += '\t\tuv.push( new THREE.UV( u2, v2 ) );\n' code += '\t\tuv.push( new THREE.UV( u3, v3 ) );\n' code += '\t\tif ( u4 && v4 ) uv.push( new THREE.UV( u4, v4 ) );\n' code += '\t\tscope.uvs.push( uv );\n' code += '\t}\n\n' code += '}\n\n' code += '%s.prototype = new THREE.Geometry();\n' % classname code += '%s.prototype.constructor = %s;' % (classname, classname) SendModelingCommand(command=MCOMMAND_REVERSENORMALS, list=[op], mode=MODIFY_ALL, bc=c4d.BaseContainer(), doc=doc) return code
def redraw(): c4d.DrawViews(c4d.DA_ONLY_ACTIVE_VIEW | c4d.DA_NO_THREAD | c4d.DA_NO_REDUCTION | c4d.DA_STATICBREAK) c4d.GeSyncMessage(c4d.EVMSG_TIMECHANGED) c4d.EventAdd(c4d.EVENT_ANIMATE | c4d.EVENT_FORCEREDRAW)
def endExport(mainDialog, exportData): #mainHelpers.deleteCopiedMeshes(exportData.allMeshObjects) if exportData is not None: if len(exportData.AWDerrorObjects) > 0: newMessage = c4d.plugins.GeLoadString(ids.ERRORMESSAGE) + "\n" for errorMessage in exportData.AWDerrorObjects: newMessage += c4d.plugins.GeLoadString(errorMessage.errorID) if errorMessage.errorData != None: newMessage += "\n\n" + str( c4d.plugins.GeLoadString( ids.ERRORMESSAGEOBJ)) + " = " + str( errorMessage.errorData) c4d.gui.MessageDialog(newMessage) if mainDialog.GetBool(ids.CBOX_CLOSEAFTEREXPORT) == True: exportData = None c4d.DrawViews(c4d.DA_ONLY_ACTIVE_VIEW | c4d.DA_NO_THREAD | c4d.DA_NO_REDUCTION | c4d.DA_STATICBREAK) c4d.GeSyncMessage(c4d.EVMSG_TIMECHANGED) c4d.EventAdd(c4d.EVENT_ANIMATE) mainDialog.Close() return True exportData = None c4d.DrawViews(c4d.DA_ONLY_ACTIVE_VIEW | c4d.DA_NO_THREAD | c4d.DA_NO_REDUCTION | c4d.DA_STATICBREAK) c4d.GeSyncMessage(c4d.EVMSG_TIMECHANGED) c4d.EventAdd(c4d.EVENT_ANIMATE) return True if len(exportData.AWDwarningObjects) > 0: newMessage = c4d.plugins.GeLoadString(ids.WARNINGMESSAGE) + "\n" for errorMessage in exportData.AWDwarningObjects: newMessage += c4d.plugins.GeLoadString(errorMessage.errorID) if errorMessage.errorData != None: newMessage += "AWDWarningObject: " + str( errorMessage.errorData) print "Warning " + str(newMessage) if mainDialog.GetBool(ids.CBOX_CLOSEAFTEREXPORT) == True: exportData = None c4d.DrawViews(c4d.DA_ONLY_ACTIVE_VIEW | c4d.DA_NO_THREAD | c4d.DA_NO_REDUCTION | c4d.DA_STATICBREAK) c4d.GeSyncMessage(c4d.EVMSG_TIMECHANGED) c4d.EventAdd(c4d.EVENT_ANIMATE) mainDialog.Close() return True if mainDialog.GetBool(ids.CBOX_CLOSEAFTEREXPORT ) == True and exportData.cancel != True: exportData = None c4d.DrawViews(c4d.DA_ONLY_ACTIVE_VIEW | c4d.DA_NO_THREAD | c4d.DA_NO_REDUCTION | c4d.DA_STATICBREAK) c4d.GeSyncMessage(c4d.EVMSG_TIMECHANGED) c4d.EventAdd(c4d.EVENT_ANIMATE) mainDialog.Close() return True exportData = None c4d.DrawViews(c4d.DA_ONLY_ACTIVE_VIEW | c4d.DA_NO_THREAD | c4d.DA_NO_REDUCTION | c4d.DA_STATICBREAK) c4d.GeSyncMessage(c4d.EVMSG_TIMECHANGED) c4d.EventAdd(c4d.EVENT_ANIMATE) maindialogHelpers.enableAll(mainDialog, True) #print c4d.plugins.GeLoadString(ids.SUCCESSMESSAGE) mainHelpers.updateCanvas(mainDialog, exportData) c4d.EventAdd(c4d.EVENT_ANIMATE) mainDialog.SetTimer(0)
def main(): coldata1 = "F:/contentIPC21.hex" doc = c4d.documents.GetActiveDocument () ctime = doc.GetTime() # Save current time # Get FPS and minimum + maximum frames fps = doc.GetFps() start = doc.GetMinTime().GetFrame(fps) end = doc.GetMaxTime().GetFrame(fps) op = doc.SearchObject('sunmatrix') #search for object in c4d to store data op2 = doc.SearchObject('skymatrix') #search for object in c4d to store data op3 = doc.SearchObject('creepyman') op4 = doc.SearchObject('ledsSoloMorning') op5 = doc.SearchObject('ledsSoloEvening') with open(coldata1, 'wb') as f: #for frame in xrange(start,end+1): frame = 0 #print c4d.BaseTime(frame,fps) while c4d.BaseTime(frame,fps) < doc.GetMaxTime(): bt = c4d.BaseTime (frame, fps) #current frame,frame rate c4d.documents.SetDocumentTime (doc, bt) #print "Document time : ", doc.GetTime().GetFrame(fps) c4d.GeSyncMessage(c4d.EVMSG_TIMECHANGED)# make the timeline, timeslider etc. do an instant redraw.) c4d.EventAdd(c4d.EVENT_ANIMATE) md = mo.GeGetMoData(op) md2 = mo.GeGetMoData(op2) md3 = mo.GeGetMoData(op3) md4 = mo.GeGetMoData(op4) md5 = mo.GeGetMoData(op5) if md==None and md2 == None and md3 == None and md4 == None and md5 == None: return False cnt = md.GetCount() marr = md.GetArray(c4d.MODATA_CLONE) carr = md.GetArray(c4d.MODATA_COLOR) cnt2 = md2.GetCount() marr2 = md2.GetArray(c4d.MODATA_CLONE) carr2 = md2.GetArray(c4d.MODATA_COLOR) cnt3 = md3.GetCount() marr3 = md3.GetArray(c4d.MODATA_CLONE) carr3 = md3.GetArray(c4d.MODATA_COLOR) cnt4 = md4.GetCount() marr4 = md4.GetArray(c4d.MODATA_CLONE) carr4 = md4.GetArray(c4d.MODATA_COLOR) cnt5 = md5.GetCount() marr5 = md5.GetArray(c4d.MODATA_CLONE) carr5 = md5.GetArray(c4d.MODATA_COLOR) c4d.DrawViews() node_count = 0 #count node allcol = [] for c, d, e,j,k in zip(carr,carr2,carr3,carr4,carr5): cx = c * 255 #multiply colour vals by 255 to get RGB r = int(cx[0]) g = int(cx[1]) b = int(cx[2]) w = int((r+g+b)/10) if(r >= 254): r = 254 if(g >= 254): g = 254 if(b >= 254): b = 254 if(w >= 254): w = 254 dx = d * 255 #multiply colour vals by 255 to get RGB r2 = int(dx[0]) g2 = int(dx[1]) b2 = int(dx[2]) w2 = int((r2+g2+b2)/10) if(r2 >= 254): r2 = 254 if(g2 >= 254): g2 = 254 if(b2 >= 254): b2 = 254 if(w2 >= 254): w2 = 254 ex = e * 255 #multiply colour vals by 255 to get RGB r3 = int(ex[0]) g3 = int(ex[1]) b3 = int(ex[2]) w3 = int((r3+g3+b3)/10) if(r3 >= 254): r3 = 254 if(g3 >= 254): g3 = 25 if(b3 >= 254): b3 = 254 if(w3 >= 254): w3 = 254 jx = j * 255 #multiply colour vals by 255 to get RGB r4 = int(jx[0]) g4 = int(jx[1]) b4 = int(jx[2]) w4 = int((r4+g4+b4)/10) if(r4 >= 254): r4 = 254 if(g4 >= 254): g4 = 254 if(b4 >= 254): b4 = 254 if(w4 >= 254): w4 = 254 kx = k * 255 #multiply colour vals by 255 to get RGB r5 = int(kx[0]) g5 = int(kx[1]) b5 = int(kx[2]) w5 = int((r5+g5+b5)/10) if(r5 >= 254): r5 = 254 if(g5 >= 254): g5 = 254 if(b5 >= 254): b5 = 254 if(w5 >= 254): w5 = 254 allcol.append(r) allcol.append(r2) allcol.append(r3) allcol.append(r4) allcol.append(r5) allcol.append(g) allcol.append(g2) allcol.append(g3) allcol.append(g4) allcol.append(g5) allcol.append(b) allcol.append(b2) allcol.append(b3) allcol.append(b4) allcol.append(b5) allcol.append(w) allcol.append(w2) allcol.append(w3) allcol.append(w4) allcol.append(w5) ipcByteArray = bytearray() ipcByteArray.append(0xFF) ipcByteArray.extend(bytearray(allcol)) node_count += 1 c4d.EventAdd(c4d.EVENT_ANIMATE) #Adds a global event to Cinema 4D’s event queue. Results in a CoreMessage() message. frame += 1 f.write(ipcByteArray) # write after every frame f.close()