Object generator plugin with tags

On 15/03/2018 at 16:01, xxxxxxxx wrote:

Is it possible to create an object generator plugin with pre-assigned tags?
For example, many of C4D's built in object generators are added with a phong tag.

Also I would like to know how is created Hair generator?
When I'm adding it to the scene, it comes with phong tag, hair tag and also it creates hair material and activates hair effect in the render settings.

I tried to hide my object generator plugin from the C4D's plugins menu and register command data plugin which creates my object generator plugin, adds the desired tags to it and also changes other settings, but when I'm creating my object generator via this command, I'm losing the ability of making it a child of the selected object by pressing the shift key or a parent object by pressing the alt key, etc.

On 16/03/2018 at 09:47, xxxxxxxx wrote:


yes, there is a way to accomplish this. You'll receive MSG_MENUPREPARE in your Message() function. This message is sent, when the user creates an object (or tag...), in order to let the plugin do some setup work.
So you won't need the Command workaround.

In our C++ docs we have some more information in the NodeData::Message() manual (including a code snippet, which shouldn't be too hard to port to Python).

On 16/03/2018 at 12:30, xxxxxxxx wrote:

Thanks. This is exactly what I wanted.

On 16/03/2018 at 12:41, xxxxxxxx wrote:

Is it possible to insert material in to the document when the object is created?
I'm getting this error message: AttributeError: 'NoneType' object has no attribute 'InsertMaterial'

    def Message(self, node, type, data) :
        if type == c4d.MSG_MENUPREPARE:
            doc = node.GetDocument()
            material = c4d.BaseMaterial(1017730)
	return True

On 16/03/2018 at 14:05, xxxxxxxx wrote:

Figured out. I had to use **data ** instead of node.GetDocument()

    def Message(self, node, type, data) :
        if type == c4d.MSG_MENUPREPARE:
            texture = node.MakeTag(1017729)
            material = c4d.BaseMaterial(1017730)
        return True