SOLVED How to use c4d.VertexColorTag in Python Generator?

I have seen a few examples on how to use set the vertex colors of geometry using Python, but the problem is that they all depend on the geometry already existing, being editable, and having a material pointing to a vertex color tag that is already on the object.

What I don't understand is how I would do this if the geometry is being created within a Python generator. If I add a material to the Python generator, I can't point the Vertex Map Shader to a vertex color tag because I can't add a vertex color tag to the Python generator without making it editable (which I don't want to do). I can use c4d.VertexColorTag to add it to the geometry, but it doesn't show up in the object manager, so I can't point the material to it.

Really, all I want is a way to color geometry that is generated within a Python generator based on the vertices specified. Does anybody have a simplified example of how I can do this?

For example, how would I have a Python generator create a cube and set a random color at each of its 8 vertices in such a way that the material with a Vertex Map Shader can display visibly? The key here is that the Python generator is not made editable, and the geometry of the cube itself is created within the Python generator.

So basically this:

06bde02f-a09c-47fa-b173-f89e98335993-image.png

entirely from within a Python generator. How can I do that?

HI:

Your problem is that the material ball is stored on the hard disk, while the polygon object generated by the Python generator is stored on the memory strip (cache).Only objects from the hard disk can be added to the cache. Cache objects must be instantiated (collapsed) to be added to the hard disk. To display shading, a material ball is required, but the vector color tag in the cache cannot be added to the material ball in the hard disk.
There are two solutions:

  1. Generate polygon object, material label, standard material ball, vector color label in cache simultaneously.
  2. Use Python tags to generate solid polygon objects instead of in memory.

@x_nerve This is really helpful, but I don't understand how to do Solution 1. Do you have an example of how to do this? All I need to do is see working Python code.

Hi:

You can generate multiple cache items in the Python generator at the same time, such as polygon objects, material labels, standard material balls, and vector color labels, but you cannot add vector color labels to material balls. Base_Objects and Base_tag can be added to cached documents at this stage, while materials cannot be added to cached documents at this stage.The vector color tag exists in the cached document, and the material exists in the active document. The material cannot receive the vector color tag in the cached document, so this is not possible.

Even though it might someday be possible to add a polygon object, a material label, a standard material ball, and a vector color label to a cached document, the renderer can only receive one document for rendering, so that's not possible.

Please use Python tags, entities to generate various objects, this is to achieve the desired effect.If done through the Python generator, the final result simply returns None, remembering to insert various objects into the current document.

hi,

it's not possible, but I've answer your other thread so we can figure out there what are the options to achieve your goal.

Cheers,
Manuel