Community
Arnold for Cinema 4D Forum
Rendering with Arnold in CINEMA 4D using the C4DtoA plug-in.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

C4DToA Python - Scripting the file paths of Arnold Driver nodes broken?

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
basvanbergen
587 Views, 4 Replies

C4DToA Python - Scripting the file paths of Arnold Driver nodes broken?

There is this great little script on the site, but I cannot get it to work.

https://support.solidangle.com/display/arnsupp/2015/10/20/%5BC4DtoA%5D+Scripting+the+file+paths+of+A...

Setting the filepath of the arnold driver using this script , clears the filepath, instead of adding the custom filepath value.

Is this a bug, or am I missing something?

Hope someone can help me out,

Thanks

Bas

Tags (2)
Labels (2)
4 REPLIES 4
Message 2 of 5

see the first example here: https://support.solidangle.com/x/aABeAg



// Stephen Blair
// Arnold Renderer Support
Message 3 of 5
basvanbergen
in reply to: basvanbergen

Thanks for the quick answer, I've been trying to get this to work, and I've got as far as creating a custom new ARNOLD_DRIVER with a custom path, but I can not get it to modify an existing arnold driver.

object.GetDataInstance() does not work with the SetParameter... I'm clearly missing the python/scripting knowledge to fix this. And I can't wrap my head around this Custom UI python script part.

Below I've pasted the code, if anyone has the time, could they have a quick look, and tell me what I'm doing wrong?

All the best!

   
    import c4d
     
    # From plugins/C4DtoA/res/c4dtoa_symbols.h
    ARNOLD_DRIVER               = 1030141
     
    # From plugins/C4DtoA/res/description/ainode_driver_exr.h
    C4DAIP_DRIVER_EXR_FILENAME  = 1285755954
     
    # From plugins/C4DtoA/res/description/arnold_driver.h
    C4DAI_DRIVER_TYPE           = 101
     
    # From plugins/C4DtoA/api/include/util/NodeIds.h
    C4DAIN_DRIVER_EXR      = 9504161
    C4DAIN_DRIVER_DEEPEXR  = 1058716317
    C4DAIN_DRIVER_JPEG     = 313466666
    C4DAIN_DRIVER_PNG      = 9492523
    C4DAIN_DRIVER_TIFF     = 313114887
    
    def main():
        exrDriver = c4d.BaseObject(ARNOLD_DRIVER)
        exrDriver.SetName("myDriver")
        path_id = c4d.DescID(c4d.DescLevel(C4DAIP_DRIVER_EXR_FILENAME), c4d.DescLevel(1))
        type_id = c4d.DescID(c4d.DescLevel(C4DAIP_DRIVER_EXR_FILENAME), c4d.DescLevel(2))
        print "Current path: %s" % exrDriver.GetParameter(path_id, c4d.DESCFLAGS_GET_0)
        print "Current type: %d" % exrDriver.GetParameter(type_id, c4d.DESCFLAGS_GET_0)
        exrDriver.SetParameter(path_id, "c:\\test\\path", c4d.DESCFLAGS_SET_0)
        exrDriver.SetParameter(type_id, 1, c4d.DESCFLAGS_SET_0)
        
        doc.InsertObject(exrDriver)
        c4d.EventAdd() 
    
    if __name__=='__main__':
        main()    
    
   


Message 4 of 5

This code is correct, it creates a new Arnold Driver named "myDriver" sets the path and adds the driver to the scene.

If you want to modify an existing Arnold Driver object, then first you have to find that object in the scene. For instance:

exrDriver = doc.SearchObject("myDriver")

and than you can set the parameters of this object:

exrDriver.SetParameter(path_id, "c:\\my\\new\\path", c4d.DESCFLAGS_SET_0)

Hope this helps.

Message 5 of 5
basvanbergen
in reply to: basvanbergen

Wow! thank you so much! Works like a charm!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report