Animated user data for Python Generator - how?



  • On 22/08/2018 at 13:39, xxxxxxxx wrote:

    I have a simple Python generator that creates some polys.

    In the Generator's User Data there is a Link for a texture tag, which gets cloned by the generator and assigned to the created polys.

    I want to allow the user to animate some of the parameters of the cloned texture tag (eg Offset and Length).

    I assume I need to create User Data elements for these parameters, so the user can animate them.

    But how do I link the User Data so that its changing values get propagated to the properties of the cloned tag created in the Generator?

    Or am I going about this the wrong way..?



  • On 23/08/2018 at 07:27, xxxxxxxx wrote:

    Hi,

    welcome to the Plugin Café forums 🙂

    You are basically on the right track.

    In the generator's main() function (which basically relates to an ObjectData plugin's Execute() function) you can simply read the user data and apply it to the clones texture tag. On every parameter change, the generator will be reevaluated automatically. The generator itself can be referenced with op.

    Simple example generating a cube with size defined by used data:

    def main() :
        cube = c4d.BaseObject(c4d.Ocube)
        if cube is None:
            return None
        size = op[c4d.ID_USERDATA, 1] # 1 is the ID of the user data
        cube[c4d.PRIM_CUBE_LEN] = c4d.Vector(size, size, size)
        return cube
    


  • On 23/08/2018 at 12:15, xxxxxxxx wrote:

    Thanks - I didn't realize the Generator would create everything anew for any parameter change!


Log in to reply