@ferdinand : I've been working for a while with the solution of GetAllAssetsNew now but Today I noticed an issue:
When a texture is used in multiple shaders, in the "Project Asset Inspector" it has a "+" before "Asset". However when I pull that texture with GetAllAssetsNew it seems that is only displaying 1 "owner" shader, even though in reality it's multiple.
When I then loop over all texture assets to convert the paths from local to global, the extra owners keep their local paths and it's only changed for one of the owner shaders.
In my example I have 4 images assinged to 5 shaders. When I pull a len() on the list of assets I get 4. Then when I convert the paths to global, one of the shaders get's left behind and in the Project Asset Inspector the "+" vanishes and I now see 5 textures instead of 4. Same goes if I then pull a len() on the list again, it now says 5.
How can I make sure that it makes paths global on all owners of the texture?
doc = c4d.documents.GetActiveDocument()
textures = 
c4d.documents.GetAllAssetsNew(doc, 0, "", flags=c4d.ASSETDATA_FLAG_TEXTURESONLY,
print("The numder of textures is: ", len(textures))
print("Textures are: ", textures)
# Extract filename from all textures and put that name into the owner (shader) using the bitmap
for texture in textures:
filePath = texture
file = os.path.split(filePath["filename"])
workPath = doc.GetDocumentPath()
globalPath = str(os.path.join(workPath, "tex"))
# Check whether the texture file is in the texture (sub)folder(s)
for texture in os.walk(globalPath):
i = 0
for filename in texture:
# print("Texture in tex folder is: ", filename)
# Check if the filenames match between the file in the shader and the file on the
if (file == filename):
globalPath = str(os.path.join(str(globalPath),str(filename)))
owner = filePath["owner"]
print("Owner is: ",filePath["owner"])
i += 1
if (i == len(texture)):
if not filePath["exists"]:
print("This file ", file, " does not exist!")
print("File ", file, " not found in the tex folder of the project, use "
"'Localize texture paths' first to copy the file to the tex folder "
"of the project")
edit: forked form https://plugincafe.maxon.net/topic/14732/ by Ferdinand.
To have your code not "messed up", you should markdown formating.
def foo: return 3.14
which would render as
def foo: return 3.14