Navigation

    • Register
    • Login
        No matches found
    • Search
    1. Home
    2. SuperHomiak
    SuperHomiak

    SuperHomiak

    @SuperHomiak

    0
    Reputation
    3
    Posts
    17
    Profile views
    0
    Followers
    1
    Following
    Joined Last Online

    • Profile
    • More
      • Following
      • Followers
      • Topics
      • Posts
      • Best
      • Groups
    SuperHomiak Follow

    Best posts made by SuperHomiak

    This user hasn't posted anything yet.

    Latest posts made by SuperHomiak

    How to Add Multiple Redshift Pazzle Matte AOVs

    Hello, everyone! Im learning python and trying to make useful stuff, but it`s hard to understand some things.

    I`m writing now a simple script for Redshift users. The task is:

    1. Add individual Object ID tags to selected objects (for examle, obj1 = 1, obj2 = 2 , ...)
    2. Create Redshift Pazzle Matte AOVs (PM)

    The trick is to make enough PM to be enough for each object that is selected in the scene.

    1 PM AOV is equal to 3 objects in scene. For example I generated 9 Object ID tags. Every tag assign uniqe number for every object (1, 2, 3, ...). For each of them I need PMs where every channel is object in scene.

    1. How to generate multiple PMs with uniqe names and increasing numbers for my Object IDs?
    2. How to improve this code?

    Thank you for your attention!

    Screenshot_1.png

    import c4d
    import c4d.documents
    from c4d import gui
    import redshift
    from pprint import pprint
    
    def ob_tags():
    
        flags = (c4d.GETACTIVEOBJECTFLAGS_SELECTIONORDER |
                 c4d.GETACTIVEOBJECTFLAGS_CHILDREN)
        selection = doc.GetActiveObjects(flags)
    
    
    
        if not selection:
            c4d.gui.MessageDialog("Please select objects")
    
        doc.StartUndo()
    
        for i, obId in enumerate(selection):
            tag = c4d.BaseList2D(1036222)
            tag[c4d.REDSHIFT_OBJECT_OBJECTID_OVERRIDE] = True
            tag[c4d.REDSHIFT_OBJECT_OBJECTID_ID] = i+1
            obId.InsertTag(tag)
            doc.AddUndo(c4d.UNDOTYPE_NEW, tag)
    
        doc.EndUndo()
    
    
    
    
    def CreateAOVs(vpRS):
        
        flags = (c4d.GETACTIVEOBJECTFLAGS_SELECTIONORDER |
                 c4d.GETACTIVEOBJECTFLAGS_CHILDREN)
        selection = doc.GetActiveObjects(flags)
        # 1 AOV is 3 channels, for 9 objects for example need 3 Pazzle Matte
        aovs_quantity = int(len(selection) // 3)
        
        #to be sure numbers ok in console
        print('aovs_quantity is ', aovs_quantity )
        print('objects in scene ', len(selection))
    
    
    
    
        aovs = redshift.RendererGetAOVs(vpRS)
        aov = redshift.RSAOV()
        aov.SetParameter(c4d.REDSHIFT_AOV_TYPE, c4d.REDSHIFT_AOV_TYPE_PUZZLE_MATTE)
        aov.SetParameter(c4d.REDSHIFT_AOV_ENABLED, True)
        aov.SetParameter(c4d.REDSHIFT_AOV_NAME, "My PuzzleMatte")
        aov.SetParameter(c4d.REDSHIFT_AOV_PUZZLE_MATTE_MODE, c4d.REDSHIFT_AOV_PUZZLE_MATTE_MODE_OBJECT_ID)
        #this is where channels need to assign
        aov.SetParameter(c4d.REDSHIFT_AOV_PUZZLE_MATTE_RED_ID, 1)
        aov.SetParameter(c4d.REDSHIFT_AOV_PUZZLE_MATTE_GREEN_ID,2)
        aov.SetParameter(c4d.REDSHIFT_AOV_PUZZLE_MATTE_BLUE_ID,3)
        aovs.append(aov)
        return redshift.RendererSetAOVs(vpRS, aovs)
    
    
    
    def main():
    
        ob_tags()
        doc = c4d.documents.GetActiveDocument()
        renderdata = doc.GetActiveRenderData()
    
        flags = (c4d.GETACTIVEOBJECTFLAGS_SELECTIONORDER |
                 c4d.GETACTIVEOBJECTFLAGS_CHILDREN)
        selection = doc.GetActiveObjects(flags)
        aovs_quantity = int(len(selection) // 3)
    
    
    
        # Get the Redshift videoPost and render settings
        vprs = redshift.FindAddVideoPost(renderdata, redshift.VPrsrenderer)
        if vprs is None:
            return
    
        # Switch renderer
        renderdata[c4d.RDATA_RENDERENGINE] = redshift.VPrsrenderer
    
    
    
        CreateAOVs(vprs)
    
    
    
    if __name__=='__main__':
        c4d.CallCommand(13957)
        c4d.EventAdd()
        main()
    
    posted in General Talk •
    RE: Stuck with loop through tags

    @zipit I appreciate your answer. Thank you very much!

    posted in General Talk •
    Stuck with loop through tags

    Hello everyone!

    I`m noobie and working on simple script that should generate on selected layers Redshift Object tag with checked Object ID Override. Also I need to make uniqe Object ID numbers by adding 1 to each tag.

    Problem: When I make loop through tags and try to increase Object ID parameters by 1 (I need 1, 2, 3,...) it pass all the tags exept the last and make the last tag Object ID parameter equal to objects quantity (9 in my case)

    1. How to increase Object ID parameters for each tags with uniqe data from 1 to {tags quantity}?
    2. How to improve this code?

    screenshot

    import c4d
    from c4d import gui
    
    
    
    def main():
        doc.StartUndo()
    
        selection = doc.GetSelection()
        collectedObjects = []
    
    
        if selection:
            for s in selection:
                collectedObjects.append(s)
        else:
            c4d.gui.MessageDialog('Please choose objects')
    
    
        for s in collectedObjects:
            tag = c4d.BaseTag(1036222)
            tag[c4d.REDSHIFT_OBJECT_OBJECTID_OVERRIDE] = True
            s.InsertTag(tag)
            doc.AddUndo(c4d.UNDOTYPE_NEW, tag)
            
            
            
        for tags in range(len(collectedObjects)):
            
            tag[c4d.REDSHIFT_OBJECT_OBJECTID_ID] += 1
            
    
            
        doc.EndUndo()    
            
            
    if __name__=='__main__':
        c4d.CallCommand(13957)
        main()
        c4d.EventAdd()
    

    Thank you for your attention!

    posted in General Talk •