Python Tag does not update during rendering



  • hello c4d guys!
    i have a problem with updating my scene during the rendering. in the viewport it's working. so i don't understand exactly how the scene updating mechanism is working and need help from you experts :)

    what i try to do:
    i have a weird alembic camera form maya, with a animated film back offset. the alembic camera in c4d does not interpret this correctly. so i calculated the translation formula and wrote a python script. as i said in the viewport it's doinge exactly what i want, but during rendering it's just frozen on the first frame. i tested it with the c4d.EventAdd() command, but it's still not working. here is my code:

    import c4d
    
    shotNumber = '0050'
    alembicCam = 'abcCam_' + shotNumber
    standardCam = 'cam_' + shotNumber
    
    
    def main():
        acbCamObj = doc.SearchObject(alembicCam)
        offsetX = acbCamObj[1028637,5103,1118]
        offsetY = acbCamObj[1028637,5103,1119]
    
    
        newCam = doc.SearchObject(standardCam)
        newCam[c4d.CAMERAOBJECT_FILM_OFFSET_X] = offsetX * 0.042107036086
        newCam[c4d.CAMERAOBJECT_FILM_OFFSET_Y] = (offsetY * 1.0043387434) * -1
    
    
    if __name__=='__main__':
        main()
    

    thanks a lot for any help!
    best,
    marc.



  • hi,

    alembic is a bit strange, this looks like a priority issue but if things gets better increasing the priority of the python tag, it still doesn't work.

    Working inside a Python Generator does seems to work as expected (kind of)

    You can retrieve the "Real Camera" by sending the message MSG_GETREALCAMERADATA to the alembic generator. Example in c++

    It does work but if you open the console, you will see that first (the time the alembic generator generate the camera) it doesn't work twice, but once the Camera is generated it's working. On my test, the render looks ok.

    import c4d
    
    shotNumber = '0050'
    alembicCam = 'abcCam_' + shotNumber
    standardCam = 'cam_' + shotNumber
    
    
    def main():
        acbCamObj = doc.SearchObject(alembicCam)
    
        if acbCamObj is None:
            raise ValueError("abc cam not found")
        # retrieve the alembic real camera
        data = dict()
        res = acbCamObj.Message(c4d.MSG_GETREALCAMERADATA, data)
    
        if not res:
            raise ValueError("cannot retrieve the abc camera data")
    
        vcam = data['res']
        if vcam is None:
            raise ValueError("vcam not found")
    
        offsetX = vcam[1118]
        offsetY = vcam[1119]
    
        newCam = doc.SearchObject(standardCam)
        newCam[c4d.CAMERAOBJECT_FILM_OFFSET_X] = offsetX * 0.042107036086
        newCam[c4d.CAMERAOBJECT_FILM_OFFSET_Y] = (offsetY * 1.0043387434) * -1.0
        print "ok"
    
    if __name__=='__main__':
        main()
    

    Cheers,
    Manuel



  • Hi there,

    where do you place your script?



  • hi,
    i put it in a Python Tag on the new camera.



  • maybe try

    newCam.Message(c4d.MSG_UPDATE)

    plus maybe

    c4d.EventAdd()



  • hi,

    alembic is a bit strange, this looks like a priority issue but if things gets better increasing the priority of the python tag, it still doesn't work.

    Working inside a Python Generator does seems to work as expected (kind of)

    You can retrieve the "Real Camera" by sending the message MSG_GETREALCAMERADATA to the alembic generator. Example in c++

    It does work but if you open the console, you will see that first (the time the alembic generator generate the camera) it doesn't work twice, but once the Camera is generated it's working. On my test, the render looks ok.

    import c4d
    
    shotNumber = '0050'
    alembicCam = 'abcCam_' + shotNumber
    standardCam = 'cam_' + shotNumber
    
    
    def main():
        acbCamObj = doc.SearchObject(alembicCam)
    
        if acbCamObj is None:
            raise ValueError("abc cam not found")
        # retrieve the alembic real camera
        data = dict()
        res = acbCamObj.Message(c4d.MSG_GETREALCAMERADATA, data)
    
        if not res:
            raise ValueError("cannot retrieve the abc camera data")
    
        vcam = data['res']
        if vcam is None:
            raise ValueError("vcam not found")
    
        offsetX = vcam[1118]
        offsetY = vcam[1119]
    
        newCam = doc.SearchObject(standardCam)
        newCam[c4d.CAMERAOBJECT_FILM_OFFSET_X] = offsetX * 0.042107036086
        newCam[c4d.CAMERAOBJECT_FILM_OFFSET_Y] = (offsetY * 1.0043387434) * -1.0
        print "ok"
    
    if __name__=='__main__':
        main()
    

    Cheers,
    Manuel



  • hi manuel,
    thanks a lot for your answer!
    i'm not sure if i understood it correctly.
    i tested it in my scene, but it didn't work. maybe you can have a short look to my scene?

    thanks a lot!!
    i'm a bit despread, because i have no idea how to solve my problem.
    best,
    marc.

    camtest_v002.c4d



  • hi,

    Do not use the python tag, use the python generator. (Create -> Generator -> Python Generator)

    92ee19f5-8105-4ae4-9d49-a583c9e98c54-image.png

    Cheers,
    Manuel



  • manuel, you are my hero!
    thanks a lot! it is working :)

    sorry, i totally missed the point with the python generator.
    i never used the generator before, i always used the tag.
    what is the difference? when should i use the tag and when the generator?

    thank you again!
    marc.



  • hi,

    we got some information in our documentation.

    For example you can't add an object in the document from a tag while the generator can return a hierarchy.
    But you can easily draw information on the viewport with a tag.

    Cheers,
    Manuel


Log in to reply