On 18/06/2015 at 14:30, xxxxxxxx wrote:
Hi,
I've been making an object and command plugin where the command plugin inserts several materials into the scene. The object plugin can effect the materials in Message() with MSG_DESCRIPTION_POSTSETPARAMETER and I have the materials marked as being used by the plugin.
First is this the best place to have the materials be updated by the object plugin? It doesn't seem like MSG_DESCRIPTION_POSTSETPARAMETER gets called with undos, so the materials aren't updated to the previous data, is there a way around this, am I using the wrong message?
Second, the materials are currently copied when the object plugin is duplicated in R14, but in R16 only a couple of the materials are copied when the object is, which makes it share half of them with the original. Are marked materials handled differently in R14 and R16?
def Message(self, node, type, data) :
if type == c4d.MSG_MULTI_MARKMATERIALS:
datainstance = node.GetDataInstance()
if data != None:
doc = node.GetDocument()
if doc == None:
return True
mat= datainstance.GetLink(idMaterialOne)
if mat == data.omat:
doc.StartUndo()
doc.AddUndo(c4d.UNDO_CHANGE_SMALL, node)
datainstance.SetLink(idMaterialOne,data.nmat)
doc.EndUndo()
mat= datainstance.GetLink(idMaterialTwo)
if mat == data.omat:
doc.StartUndo()
doc.AddUndo(c4d.UNDO_CHANGE_SMALL, node)
datainstance.SetLink(idMaterialTwo,data.nmat)
doc.EndUndo()
mat= datainstance.GetLink(idMaterialThree)
if mat == data.omat:
doc.StartUndo()
doc.AddUndo(c4d.UNDO_CHANGE_SMALL, node)
datainstance.SetLink(idMaterialThree,data.nmat)
doc.EndUndo()
mat= datainstance.GetLink(idMaterialFour)
if mat == data.omat:
doc.StartUndo()
doc.AddUndo(c4d.UNDO_CHANGE_SMALL, node)
datainstance.SetLink(idMaterialFour,data.nmat)
doc.EndUndo()
elif data == None:
mat= datainstance.GetLink(idMaterialOne)
if mat:
mat.SetBit(c4d.BIT_MATMARK)
mat= datainstance.GetLink(idMaterialTwo)
if mat:
mat.SetBit(c4d.BIT_MATMARK)
mat= datainstance.GetLink(idMaterialThree)
if mat:
mat.SetBit(c4d.BIT_MATMARK)
mat= datainstance.GetLink(idMaterialFour)
if mat:
mat.SetBit(c4d.BIT_MATMARK)
Thanks for any help,
Dan