SOLVED Cannot modify Lens Effects

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!


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']

Assignment before: 'col' =  Vector(0, 0, 0)
Assignment After: 'col' =  Vector(0, 0, 0)

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']

# Execute main()
if __name__=='__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.

@m_adam Thank you. Thank you very much!