Marking and Undoing Matierals.



  • 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



  • On 19/06/2015 at 09:15, xxxxxxxx wrote:

    Hi Dan,

    for your first problem, you may be hitting a Python limitation.

    The proper place to handle this would be in SetDParameter(), which is unfortunately not available in Python.
    Then we thought about another solution, using MSG_DESCRIPTION_INITUNDO, but unfortunately the accompanying data structure DescriptionInitUndo doesn't exist in Python, either.

    Links go to the C++ API docs, just so you may get an idea how it may work in a C++ plugin.

    Now, for your second question, I'm actually not quite sure I understand correctly and you may have to provide me with some more details.
    So you have materials generated in your Command Plugin. And then you have an Object Generator, which influences these materials.
    How is the connection between the materials and the object? Is it just links in the BaseContainer of the object? Or are there texture tags involved?
    And when you speak of copying/duplicating the object, is it in the same document? Or are we speaking about copy&paste into another scene?



  • On 19/06/2015 at 14:07, xxxxxxxx wrote:

    Hi Andreas,

    That's really unfortunate.  No way to work around it?  Converting the plugin to C++ isn't an option at the moment.   Would there be a way to just trigger another refresh so the materials get re-updated to the now undo-ed parameters?

    For the second question.

    Originally posted by xxxxxxxx

    So you have materials generated in your Command Plugin. And then you have an Object Generator, which influences these materials.

    That is correct, I have the materials connected to the objects via links in the basecontainer.  It works correctly when I copy my plugin to a new scene, however when pasting it into the same scene  it doesn't work correctly.   Two of my materials were copying correctly because they had inexcludes in them references the plugin object, I assume, since the other materials didn't have them.  I hope that helps.

    Thanks for the help,
    Dan


Log in to reply