Hi, I work between a Mac and PC and because of this, getting texture paths to work is less than ideal since both OS's don't use the same paths. I can reconnect the paths manually by going into the Project Asset Manager and doing a find and replace. But this can get tedious. Is there a way to automate this process with a script? So that it will detect the OS and change all relevant file locations to the correct ones? I know nothing about coding so any help would be appreciated!
Hi @ktheorin1, thanks for reaching out us and welcome to the Forum.
To find all the assets in a given scene you can use the BaseDocument::GetAllAssetsNew() which returns you a list of dictionaries with all the assets contained in a document.
The example below retrieves all the textures in the active document and append the string "_replaced" at the end of it
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()
# notify Cinema about the changes
It's also worthy having a look at the maxon::Url to handy manage the path of the retrieved textures.