Initializing compositing-tag problem



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 30/10/2011 at 08:41, xxxxxxxx wrote:

    Hey guys, new day, new problem.
    So I need to initialize compositing tags, a lot of them. They need to have different states concerning "seen by camera", "seen by reflection", etc. but their object buffers need to be the same.
    I started with one object and one tag for testing things:

    import c4d  
    from c4d import gui  
    #Welcome to the world of Python  
      
    def main() :  
      
    object = doc.GetActiveObject(False)  
    tags = object.GetTags()  
    for item in tags:  
    if item.GetType() == c4d.Tcompositing:  
    item[c4d.COMPOSITINGTAG_ENABLECHN0] = True  
    item[c4d.COMPOSITINGTAG_ENABLECHN1] = True  
    item[c4d.COMPOSITINGTAG_ENABLECHN2] = True  
    item[c4d.COMPOSITINGTAG_ENABLECHN3] = True  
    item[c4d.COMPOSITINGTAG_ENABLECHN4] = True  
    item[c4d.COMPOSITINGTAG_ENABLECHN5] = True  
    item[c4d.COMPOSITINGTAG_ENABLECHN6] = True  
    item[c4d.COMPOSITINGTAG_ENABLECHN7] = True  
    item[c4d.COMPOSITINGTAG_ENABLECHN8] = True  
    item[c4d.COMPOSITINGTAG_ENABLECHN9] = True  
    item[c4d.COMPOSITINGTAG_ENABLECHN10] = True  
    item[c4d.COMPOSITINGTAG_ENABLECHN11] = True  
      
    item[c4d.COMPOSITINGTAG_IDCHN0] = rendertag[c4d.COMPOSITINGTAG_IDCHN0]  
    item[c4d.COMPOSITINGTAG_IDCHN1] = rendertag[c4d.COMPOSITINGTAG_IDCHN1]  
    item[c4d.COMPOSITINGTAG_IDCHN2] = rendertag[c4d.COMPOSITINGTAG_IDCHN2]  
    item[c4d.COMPOSITINGTAG_IDCHN3] = rendertag[c4d.COMPOSITINGTAG_IDCHN3]  
    item[c4d.COMPOSITINGTAG_IDCHN4] = rendertag[c4d.COMPOSITINGTAG_IDCHN4]  
    item[c4d.COMPOSITINGTAG_IDCHN5] = rendertag[c4d.COMPOSITINGTAG_IDCHN5]  
    item[c4d.COMPOSITINGTAG_IDCHN6] = rendertag[c4d.COMPOSITINGTAG_IDCHN6]  
    item[c4d.COMPOSITINGTAG_IDCHN7] = rendertag[c4d.COMPOSITINGTAG_IDCHN7]  
    item[c4d.COMPOSITINGTAG_IDCHN8] = rendertag[c4d.COMPOSITINGTAG_IDCHN8]  
    item[c4d.COMPOSITINGTAG_IDCHN9] = rendertag[c4d.COMPOSITINGTAG_IDCHN9]  
    item[c4d.COMPOSITINGTAG_IDCHN10] = rendertag[c4d.COMPOSITINGTAG_IDCHN10]  
    item[c4d.COMPOSITINGTAG_IDCHN11] = rendertag[c4d.COMPOSITINGTAG_IDCHN11]  
    break  
      
    c4d.EventAdd()  
    if __name__=='__main__':  
      main()
    

    The strange thing is, that it sometimes works, and sometimes I get this error message:
    "TypeError: __setitem__ expected c4d.BaseList2D, not bool" concerning one (not always the same) COMPOSITINGTAG_ENABLECHN -states.
    I also tried to allocate with values from other rendertags and there I get something just the other way around "TypeError: __setitem__ expected bool or int, not c4d.BaseList2D" 
    Would be really glad if someone could explain this behavior to me.
    cheers
    Phil



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 30/10/2011 at 12:01, xxxxxxxx wrote:

    Hi, where do you define _rendertag  _?



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 30/10/2011 at 12:29, xxxxxxxx wrote:

    Hehe, sorry I forgot to update the code.
    Nevermind the "rendertag", I have fixed values there like:
     item[c4d.COMPOSITINGTAG_IDCHN0] = 1
     item[c4d.COMPOSITINGTAG_IDCHN1] = 2

    I don't have problems with these, just with the enabling of the buffers.
    Sorry again for the incorrect code.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 03/11/2011 at 08:47, xxxxxxxx wrote:

    I created a Compositing Tag, and executed the following code

    import c4d
    from c4d import gui
    #Welcome to the world of Python
      
    def main() :
      
        object = doc.GetActiveObject() #removed False for R13
        tags = object.GetTags()
        for item in tags:
            if item.GetType() == c4d.Tcompositing:
                item[c4d.COMPOSITINGTAG_ENABLECHN0] = True
                item[c4d.COMPOSITINGTAG_ENABLECHN1] = True
                item[c4d.COMPOSITINGTAG_ENABLECHN2] = True
                item[c4d.COMPOSITINGTAG_ENABLECHN3] = True
                item[c4d.COMPOSITINGTAG_ENABLECHN4] = True
                item[c4d.COMPOSITINGTAG_ENABLECHN5] = True
                item[c4d.COMPOSITINGTAG_ENABLECHN6] = True
                item[c4d.COMPOSITINGTAG_ENABLECHN7] = True
                item[c4d.COMPOSITINGTAG_ENABLECHN8] = True
                item[c4d.COMPOSITINGTAG_ENABLECHN9] = True
                item[c4d.COMPOSITINGTAG_ENABLECHN10] = True
                item[c4d.COMPOSITINGTAG_ENABLECHN11] = True
                break
      
        c4d.EventAdd()
    if __name__=='__main__':
        main()
    

    All buffers of the attached Compositing Tag are enabled. Which version do you use? Have you the latest version of your C4D installation?

    Cheers, Seb



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 04/11/2011 at 01:51, xxxxxxxx wrote:

    Yep using the latest version 13.029.
    I don't get it, if I create new scenes and new tags it seems to work. If I open older scenes it sometimes gives me the error messages.
    I've attached a file where it works on one object(Level1) and on the others it doesn't (Levels2.1, 2.2). It works if I activate and then deactivate the buffers.
    http://dl.dropbox.com/u/1262854/\_C4D_stuff/composite_tag-test.zip

    Anyway most times it works now, and I inserted some exceptions, so I have direct feedback If something goes wrong.
    Thanks for looking into it, maybe I just have some messed-up scenes (some of them are from R9.5).



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 04/11/2011 at 07:20, xxxxxxxx wrote:

    I can reproduce this. When the scene is from version 9.5 it might be that the datatypes at these IDs were updated and so they are not valid anymore.

    __setitem__ of BaseList2D checks the datatype before they are set. When they are incompatible this call raises an exception. Actually obj[id] is recommended but in this case check out the following code which (force) overwrites the data of your tag. See following example:

    import c4d
    from c4d import gui
    #Welcome to the world of Python
      
    def main() :
      
        object = doc.GetActiveObject() #removed False for R13
        tags = object.GetTags()
        for item in tags:
            if item.GetType() == c4d.Tcompositing:
                bc=item.GetDataInstance()
                bc.SetBool(c4d.COMPOSITINGTAG_ENABLECHN0, True)
                bc.SetBool(c4d.COMPOSITINGTAG_ENABLECHN1, True)
                bc.SetBool(c4d.COMPOSITINGTAG_ENABLECHN2, True)
                bc.SetBool(c4d.COMPOSITINGTAG_ENABLECHN3, True)
                bc.SetBool(c4d.COMPOSITINGTAG_ENABLECHN4, True)
                bc.SetBool(c4d.COMPOSITINGTAG_ENABLECHN5, True)
                bc.SetBool(c4d.COMPOSITINGTAG_ENABLECHN6, True)
                bc.SetBool(c4d.COMPOSITINGTAG_ENABLECHN7, True)
                bc.SetBool(c4d.COMPOSITINGTAG_ENABLECHN8, True)
                bc.SetBool(c4d.COMPOSITINGTAG_ENABLECHN9, True)
                bc.SetBool(c4d.COMPOSITINGTAG_ENABLECHN10, True)
                bc.SetBool(c4d.COMPOSITINGTAG_ENABLECHN11, True)
                break
      
        c4d.EventAdd()
    if __name__=='__main__':
        main()
    


  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 05/11/2011 at 00:56, xxxxxxxx wrote:

    Great that works, thank you very much.


Log in to reply