Sometimes, for example, to maintain compatibility, it's essential to know the current C4DtoA or Arnold version in a python script.

Message

To do this, you have to send a message to the Arnold scene hook registered by the plugin. If the scene hook does not exist it means C4DtoA is not installed.

Message idC4DTOA_MSG_GET_VERSION = 1040
Parameters-
Return values

C4DTOA_MSG_RESP1 = 2011 (String): C4DtoA version string.

C4DTOA_MSG_RESP2 = 2012 (String): Arnold version string.

C4DTOA_MSG_RESP3 = 2013 (Int32): C4DtoA c++ API version number.

3000 (Int32): C4DtoA arch version number.

3001 (Int32): C4DtoA major version number.

3002 (Int32): C4DtoA minor version number.

3003 (Int32): C4DtoA fix version number.

3004 (String): C4DtoA dev version token. Does not available in release builds.

4000 (Int32): Arnold arch version number.

4001 (Int32): Arnold major version number.

4002 (Int32): Arnold minor version number.

4003 (String): Arnold fix version.

Example

The following example shows how to access the version string or numbers:

import c4d

ARNOLD_SCENE_HOOK = 1032309
C4DTOA_MSG_TYPE = 1000
C4DTOA_MSG_GET_VERSION = 1040
C4DTOA_MSG_RESP1 = 2011
C4DTOA_MSG_RESP2 = 2012
C4DTOA_MSG_RESP3 = 2013

def GetC4DtoAVersion():
    arnoldSceneHook = doc.FindSceneHook(ARNOLD_SCENE_HOOK)
    if arnoldSceneHook is None:
        return ""
    
    msg = c4d.BaseContainer()
    msg.SetInt32(C4DTOA_MSG_TYPE, C4DTOA_MSG_GET_VERSION)
    arnoldSceneHook.Message(c4d.MSG_BASECONTAINER, msg)
    
    return msg.GetString(C4DTOA_MSG_RESP1)

def GetC4DtoAVersionNum():
    arnoldSceneHook = doc.FindSceneHook(ARNOLD_SCENE_HOOK)
    if arnoldSceneHook is None:
        return ""
    
    msg = c4d.BaseContainer()
    msg.SetInt32(C4DTOA_MSG_TYPE, C4DTOA_MSG_GET_VERSION)
    arnoldSceneHook.Message(c4d.MSG_BASECONTAINER, msg)
    
    arch = msg.GetInt32(3000)
    major = msg.GetInt32(3001)
    minor = msg.GetInt32(3002)
    fix = msg.GetInt32(3003)
    dev = msg.GetString(3004)
    return (arch, major, minor, fix, dev)

def GetArnoldVersion():
    arnoldSceneHook = doc.FindSceneHook(ARNOLD_SCENE_HOOK)
    if arnoldSceneHook is None:
        return ""
    
    msg = c4d.BaseContainer()
    msg.SetInt32(C4DTOA_MSG_TYPE, C4DTOA_MSG_GET_VERSION)
    arnoldSceneHook.Message(c4d.MSG_BASECONTAINER, msg)
    
    return msg.GetString(C4DTOA_MSG_RESP2)

def GetArnoldVersionNum():
    arnoldSceneHook = doc.FindSceneHook(ARNOLD_SCENE_HOOK)
    if arnoldSceneHook is None:
        return ""
    
    msg = c4d.BaseContainer()
    msg.SetInt32(C4DTOA_MSG_TYPE, C4DTOA_MSG_GET_VERSION)
    arnoldSceneHook.Message(c4d.MSG_BASECONTAINER, msg)
    
    arch = msg.GetInt32(4000)
    major = msg.GetInt32(4001)
    minor = msg.GetInt32(4002)
    fix = msg.GetString(4003)
    return (arch, major, minor, fix)

def main():
    print "C4DtoA version:", GetC4DtoAVersion()
    print "C4DtoA version num:", GetC4DtoAVersionNum()
    print "Arnold version:", GetArnoldVersion()
    print "Arnold version num:", GetArnoldVersionNum()

if __name__=='__main__':
    main()
  • No labels
© 2020-2021 Autodesk. All Rights Reserved / website terms / privacy/cookies / ccpa settings