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

    Cannot modify Lens Effects

    Cinema 4D SDK
    2
    3
    626
    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.
    • S
      sean
      last edited by m_adam

      I want to change the lens effets Settings, but I can't. I'm using python.
      Why is that? Is there any other way? Can you provide sample code? Thank you very much!

      code:
      
      def main():
          lightObj = op.GetObject()
          
          print "Assignment before: 'col' = ", lightObj[c4d.LIGHT_LENSEFFECTS_GLOW].streak[0]['col']
      
          lightObj[c4d.LIGHT_LENSEFFECTS_GLOW].streak[0]['col'] = c4d.Vector(1, 0, 0)
          
          print "Assignment After: 'col' = ", lightObj[c4d.LIGHT_LENSEFFECTS_GLOW].streak[0]['col']
      
      result:
      
      Assignment before: 'col' =  Vector(0, 0, 0)
      Assignment After: 'col' =  Vector(0, 0, 0)
      
      1 Reply Last reply Reply Quote 0
      • M
        m_adam
        last edited by

        Hi @sean, first of all, welcome in the plugincafe community.

        So the main issue is light[c4d.LIGHT_LENSEFFECTS_GLOW] returns you a copy of the GlowStruct and GlowStruct.streak also return you a copy of the list (unfortunately this can't be changed it's on our implementation for some safeties reason).
        So here is how to do it.

        import c4d
        
        def UpdateStreak(light, streakId, color):
            # Retrieves the copy of the glow struct
            glowStruct = light[c4d.LIGHT_LENSEFFECTS_GLOW]
            
            # Retrieves the copy of the list
            streakList = glowStruct.streak
            
            if streakId >= len(streakList):
                raise ValueError("Streak Id is bigger than the number of streak.")
            
            # Defines the color
            streakList[streakId]['col'] = c4d.Vector(1, 0, 0)
            
            # Defines the modified list of streak
            glowStruct.streak = streakList
            
            # Defines the modified GlowStruct
            light[c4d.LIGHT_LENSEFFECTS_GLOW] = glowStruct
        
        def main():
            print "Assignment before: 'col' = ", op[c4d.LIGHT_LENSEFFECTS_GLOW].streak[0]['col']
            UpdateStreak(op, 0, c4d.Vector(1, 0, 0))
            print "Assignment After: 'col' = ", op[c4d.LIGHT_LENSEFFECTS_GLOW].streak[0]['col']
            c4d.EventAdd()
        
        
        # Execute main()
        if __name__=='__main__':
            main()
        

        Documentation will be improved.

        Finally, few rules, don't worry I've setup correctly your topic since its the first one, but please try to follow them for your next topics.
        - Q&A New Functionality.
        - How to Post Questions.

        If you have any question, please let me know.
        Cheers,
        Maxime.

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        S 1 Reply Last reply Reply Quote 1
        • S
          sean @m_adam
          last edited by

          @m_adam Thank you. Thank you very much!

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