Set value of a fieldlayer parameter
-
good morning
I'd like to change a parameter of a fieldlayer (the radius - see attached image), but I have no luck.
I'm able to access the value, but I did not find a way to set it.
the forum search wasn't successful either, or I did not know what to look for.maybe some similar situations had been covered before.
some hints would be nice.# his is how i access the value: fields = emboss_generator[c4d.ID_USERDATA,4] f_layer = fields.GetLayersRoot().GetFirst() print ( f_layer[1002] ) # prints 7.0 # tried setting the parameter with: f_layer[1002] = .5 # or f_layer.SetParameter(1002, 0.5, c4d.DESCFLAGS_GET_NONE ) print ( f_layer[1002] ) # it will print 0.5 # but the value will not be set in the fieldlist
-
Hey @datamilch,
Thank you for reaching out to us. Please share executable code when asking questions, we can only guess what you are actually doing exactly otherwise. The likely cause for your problem is that you do not write your field data back.
Cheers,
FerdinandCode:
"""Must be run as a Script Manager script with an object selected that has a FIELDS parameter such as the Bend object for example. """ import c4d def main() -> None: """Called by Cinema 4D when the script is being executed. """ # op must be an object with MoGraph fields support, e.g., a bend object. fields = op[c4d.FIELDS] f_layer = fields.GetLayersRoot().GetFirst() f_layer[1002] = .5 # Unless we write the field data back, our changes won't be applied. print (1, op[c4d.FIELDS, 11, 1002]) op[c4d.FIELDS] = fields print (2, op[c4d.FIELDS, 11, 1002]) c4d.EventAdd() if __name__ == '__main__': main()
-
hi @ferdinand,
this solved it, thanks! I suspected, that I would have to write back the data, as in many other cases. but I didn't know how exactly.As for the executable code: will do so, next time!
cheers Sebastian