Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python 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

    physical renderer switch on problem

    Scheduled Pinned Locked Moved PYTHON Development
    7 Posts 0 Posters 743 Views
    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.
    • H Offline
      Helper
      last edited by

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 09/03/2012 at 03:35, xxxxxxxx wrote:

      Hi there,

      once again the render settings 🙂

      I have a new scene. and I try to switch on the physical renderer with python. with a script like this:

        
      import c4d   
      from c4d import gui, documents   
        
      def main() :   
          doc = documents.GetActiveDocument()   
          rd = doc.GetActiveRenderData()   
        
          def SetREN_physical(rd) :   
              rd[c4d.RDATA_RENDERENGINE] = c4d.RDATA_RENDERENGINE_PHYSICAL   
              c4d.EventAdd()   
        
          SetREN_physical(rd)   
        
      if __name__=='__main__':   
          main()   
      

      the renderengine in the dropdown (rendersettings) is named Physical,
      but there is no "posteffect" Physical in the posteffect list, and if you hit render still the standard renderer is rendering.

      If you have a new Dokument and you switch to physical renderer by hand and then back to standard by hand. and after that execute the script. the "posteffect" Physical will be there and the physical renderer will be the one to render.

      the Question:
      Is there a right/better way to switch to physical. so that it works even if the user did not switch physical and back before by hand?

      thanks a lot
      Jops

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 09/03/2012 at 09:05, xxxxxxxx wrote:

        Hello, Jops!

        As the Physical video post is not inserted automatically, we have to do it on our own. We can use c4d.BaseList2D with the appropriate constant to instantiate a new video post. However, finding constants is not always easy. To find out that the type-identifier of the Physical video post is c4d.VPxmbsampler, I did the following:

        1. Printed the type of the Physical video post to the console, using c4d.C4DAtom.GetType()
        2. Iterated through the contents of the Cinema 4D module and print out the names whose values are equal to the id
        def main() :
            for k, v in c4d.\__dict\_\_.iteritems() :
                if v == 1023342:
                    print k  
        main()   
        

        This reveals 2 items, c4d.RDATA_RENDERENGINE_PHYSICAL and c4d.VPxmbsampler. Since all Video-Post type-constants start with VP we're not going to use c4d.RDATA_RENDERENGINE_PHYSICAL as the values of the constants could differ in the next release of Cinema 4D.

        # Set's the Cinema 4D's renderer to the Physical Sampler
        
        import c4d
        
        def main() :
            rdata   = doc.GetActiveRenderData()
            vpost   = rdata.GetFirstVideoPost()
            rdata[c4d.RDATA_RENDERENGINE] = c4d.RDATA_RENDERENGINE_PHYSICAL
        
            while vpost:
                if vpost.CheckType(c4d.VPxmbsampler) : break
                vpost = vpost.GetNext()
        
            if not vpost:
                vpost = c4d.BaseList2D(c4d.VPxmbsampler)
                rdata.InsertVideoPost(vpost)
        
            c4d.EventAdd()
        
        main()
        

        Cheers!
        -Niklas

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 12/03/2012 at 06:57, xxxxxxxx wrote:

          Hi Niklas,
          once again thanks for your help 🙂

          I am not shure if I understand the "if not" completely
          So I changed the code to my Pidgin-Python. It works as far as I can see.
          Is there any reason I shoudnt do this?

          thanks
          Jops

            
          import c4d   
            
          def main() :   
              rdata   = doc.GetActiveRenderData()   
              vpost   = rdata.GetFirstVideoPost()   
              rdata[c4d.RDATA_RENDERENGINE] = c4d.RDATA_RENDERENGINE_PHYSICAL   
                 
              physical_on = False   
                 
              while vpost:   
                  if vpost.CheckType(c4d.VPxmbsampler) :   
                      physical_on = True   
                  vpost = vpost.GetNext()   
            
              if physical_on == False:   
                  vpost = c4d.BaseList2D(c4d.VPxmbsampler)   
                  rdata.InsertVideoPost(vpost)   
            
              c4d.EventAdd()   
            
          main()   
          
          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

            On 12/03/2012 at 10:54, xxxxxxxx wrote:

            Hi Jops,

            if not vpost:
              # ...

            equals your physical_on. When a Physical VP was found while iterating over the video-posts, the while loop will stop immediately because of the break keyword. In  the other case, vpost will equal None because the last video-post in the list will return None on ~.GetNext() or rdata.GetFirstVideoPost() returns None (i.e. no video-posts are available)and no iteration will take place at all .

            Cheers,
            niklas

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

              On 13/03/2012 at 05:22, xxxxxxxx wrote:

              Hi Niklas,

              so :
              if not vpost:

              is the same as:
              if vpost == None:

              ?

              best regards
              Jops

              1 Reply Last reply Reply Quote 0
              • H Offline
                Helper
                last edited by

                THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                On 13/03/2012 at 05:42, xxxxxxxx wrote:

                Hi Jops,

                well, not exactly. This has nothing to do with Cinema 4D but with Python itself.

                if obj:
                  # ...

                Checks an object for it's truth value. It is equal to

                if bool(obj) == True:
                  # ...

                This implicit checking is necessary because Python is a type-less language.

                if obj == True:
                  # ...

                requires obj to be exactly True. If obj is a string, an integer or any other object, the if condition will evaluate to False. Never check for truth-value explicit.

                Cheers,
                Niklas

                1 Reply Last reply Reply Quote 0
                • H Offline
                  Helper
                  last edited by

                  THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                  On 13/03/2012 at 06:47, xxxxxxxx wrote:

                  Hi Niklas,

                  I guess I will need some time to get my head around this. but I think I got the direction 🙂

                  again and again, Thanks a lott
                  Jops

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