For our render farm (Drop & Render) we upload a project from a user and render this on our farm. For this all assets of the project must of course be relinked or need to be relative.
To do this we have special script that run and can change any path before the jobs starts running. But one thing is currently not possible. (Or not so far I know of) And that is changing the paths that are in the project asset inspector. You can get all assets with GetAllAssets() or GetAllTextures() but there is no SetAllAssets where you can give it a dictionary back. Our current workaround is that we always duplicate and save the project before uploading to make all paths relative. With the a function like above this would not be necessary anymore and we can upload without any extra steps.
We tried multiple workarounds, looping over all textures for example. You can get pretty far, but node materials have no python accessibility and some third party render engine are pretty hard to get the textures. For example Cycles4D does not have a python functions.
Long story short. It would be so powerful for us if we can adjust all assets in the Project Asset Inspector with something like SetAllAssets. I know a few more people have requested it, is this something you guys can create?
Thanks in advance!
Hi @jwzegelaar, thanks for reaching out to us.
I see your points and:
textures = list()
# execute the GetAllAssetsNew for the current document
c4d.documents.GetAllAssetsNew(doc, False, "", c4d.ASSETDATA_FLAG_TEXTURESONLY, textures)
for t in textures:
textureOwner = t["owner"]
textureURL = maxon.Url(t["filename"])
# get the texture suffix
textureSuffix = textureURL.GetSuffix()
# remove the suffix from the URL
# replace the name by adding the word "_replaced"
textureURL.SetName(textureURL.GetName() + "_replaced")
# set again the suffix to the URL
#update the textureOwner parameter
textureOwner[c4d.BITMAPSHADER_FILENAME] = textureURL.GetSystemPath() // depends on the material param description: be sure to use the proper descID!
# notify Cinema about the changes
Thank you very much for this respond.
The method below is something we tried in the past but it's not updating all types of materials and assets. We got many unexpected results with this. It never works correctly it seems. And because you need to use the prober ID it faces the same limitations.
wrt textures used in external materials whose parameters are not handled using Cinema 4D parameters description (see Octane materials definition) it's up to the external renderer vendor to eventually provide a python API to access and manipulate their materials
Yes we are fully aware of this. But this is all not needed in my option. If we go to the project asset inspector and manually change the path of the file. No matter if it's octane a node material or an object in the scene. The path will update inside C4D. With that in place it sounds very easy to be able to update the path with Python.
With the SetAllAssets() command pass the same dictionary back just with adjusted paths. This was just my idea but there probably way beter solutions for this. The goal is, adjust path of the assets inspector.
Would still love if you guys can create something that enabled you to change assets paths with python.
Hopefully it can be added to the feature list.