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

    Set value of a fieldlayer parameter

    Cinema 4D SDK
    windows python 2023
    2
    3
    498
    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.
    • D
      datamilch
      last edited by datamilch

      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.

      fieldlist 01.JPG

      # 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
      
      ferdinandF 1 Reply Last reply Reply Quote 0
      • ferdinandF
        ferdinand @datamilch
        last edited by ferdinand

        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,
        Ferdinand

        Code:

        """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()
        

        MAXON SDK Specialist
        developers.maxon.net

        D 1 Reply Last reply Reply Quote 0
        • D
          datamilch @ferdinand
          last edited by

          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

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