ObjectPlugin and material

On 15/11/2017 at 07:20, xxxxxxxx wrote:

I have an objectplugin with 2 children.
In GetVirtualObjects(), the children are placed under a Boolean and converted to a mesh using MCOMMAND_CURRENTSTATETOOBJECT.

That is all ok, but when I place a texture behind the generator and a second texture on one of the children, the texture on the generator is not displayed. The texture on the child is displayed.

- generator + texture
  - child 1
  - child 2 + texture

I am obviously forgetting a flag, but which one?
Here the code:

    def GetVirtualObjects(self, op, hierarchyhelp) :
        doc = op.GetDocument()
        if op.GetDown() is None or op.GetDown().GetNext() is None:
            return c4d.BaseObject(c4d.Onull)
        res = op.GetAndCheckHierarchyClone(hierarchyhelp, op.GetDown(), c4d.HIERARCHYCLONEFLAGS_0, True)
        if res['dirty'] == False:
            return res['clone']
        objA = res['clone'].GetDown()
        objB = objA.GetNext()
        boolObj = c4d.BaseObject(c4d.Oboole) 
        boolObj[c4d.BOOLEOBJECT_HIGHQUALITY] = True
        boolObj[c4d.BOOLEOBJECT_SINGLE_OBJECT] = True 
        boolObj[c4d.BOOLEOBJECT_SEL_CUT_EDGES] = True
        boolObj[c4d.BOOLEOBJECT_HIDE_NEW_EDGES] = True
        boolObj[c4d.BOOLEOBJECT_BREAK_CUT_EDGES] = True
        boolObj[c4d.BOOLEOBJECT_TYPE] = 1
        objList = c4d.utils.SendModelingCommand(
            command = c4d.MCOMMAND_CURRENTSTATETOOBJECT,
            list = [boolObj],
            mode = c4d.MODELINGCOMMANDMODE_ALL,
            doc = doc)
        if objList == False:
            #print "Error Current State to object Bool!"  
            return None
        return objList[0]

On 15/11/2017 at 07:41, xxxxxxxx wrote:

Didn't remember in which post I read that (but I remember to have read inside plugincafe), that you need to create texturetag / uv yourself.

Could be wrong since it's something I get in my far far memories, and never really tested.

EDIT: https://plugincafe.maxon.net/topic/5148/5133_generator-plugin-problems-with-tags

So it's looks like you can't create Material ( wich is obvious since, it's a threaded function), but you can create tag and assign Material within a GetVirtualObjects environment.
You also seem to need a proper uv projection.

Hope it's help.

On 15/11/2017 at 10:04, xxxxxxxx wrote:

I did some further investigation and I think it has to do with the behavior of MCOMMAND_CURRENTSTATETOOBJECT (CSTO)

What I detected is that CSTO:
* returns a Null, with the csto result as child of that Null and with the texture assigned to the null, if there is a texture on one of the children

- generator + texture 1
  - child 1
  - child 2 + texture 2

-  csto result + texture
- Null + texture 1
  - csto result + texture 2

* returns the csto result with the texture assigned to this csto result, if there is NO texture assigned to the children.

- generator + texture 1
  - child 1
  - child 2

-  csto result + texture 1

So, I guess I have to check whether csto returned a Null and then add the texture to its child.


PS See also https://plugincafe.maxon.net/topic/648/13804_strange-behavior-boolean

On 16/11/2017 at 08:48, xxxxxxxx wrote:

Hi Pim,

we discussed your question in today's meeting, but we came to the conclusion, we don't fully understand, what you are trying to achieve.

Maybe you can provide us with some details:
How does the setup look like in OM?
What's the desired outcome?
Or maybe you can show some code, how you try to assign the materials?

In order to not leave you with questions only, OBJECT_USECACHECOLOR might have an influence, but without having understood, that's of course difficult to say for sure...