Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Python Tag does not update during rendering

    Cinema 4D SDK
    python
    4
    9
    1.1k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      marc_angele
      last edited by marc_angele

      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.

      1 Reply Last reply Reply Quote 0
      • M
        mp5gosu
        last edited by

        Hi there,

        where do you place your script?

        1 Reply Last reply Reply Quote 0
        • M
          marc_angele
          last edited by

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

          1 Reply Last reply Reply Quote 0
          • indexofrefractionI
            indexofrefraction
            last edited by indexofrefraction

            maybe try

            newCam.Message(c4d.MSG_UPDATE)

            plus maybe

            c4d.EventAdd()

            1 Reply Last reply Reply Quote 0
            • ManuelM
              Manuel
              last edited by

              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

              MAXON SDK Specialist

              MAXON Registered Developer

              1 Reply Last reply Reply Quote 0
              • M
                marc_angele
                last edited by

                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

                1 Reply Last reply Reply Quote 0
                • ManuelM
                  Manuel
                  last edited by Manuel

                  hi,

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

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

                  Cheers,
                  Manuel

                  MAXON SDK Specialist

                  MAXON Registered Developer

                  1 Reply Last reply Reply Quote 0
                  • M
                    marc_angele
                    last edited by

                    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.

                    1 Reply Last reply Reply Quote 0
                    • ManuelM
                      Manuel
                      last edited by

                      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

                      MAXON SDK Specialist

                      MAXON Registered Developer

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post