Globalize FilePath

On 01/05/2014 at 20:29, xxxxxxxx wrote:

I am writing a python script in c4d and i need some help.

The script i have written requires the global(absolute) filepath of the textures.
As, i require it to copy the texture file into a new directory.

Currently, i have resorted to using call command, to get the filepath:

c4d.CallCommand(1029486) #Open Texture Manager
c4d.CallCommand(1029813) #Select All texture
c4d.CallCommand(1029820) #Globalize filenames

But i know that this is method may lead to complications in the future.

I have tried googling every possible term i can think of, and i still have not
come up with a solution.
So i would like to know if anyone can help me, with how i would go along writing a
python alternative on how to get the global(absolute) filepath.


On 02/05/2014 at 06:16, xxxxxxxx wrote:

You need to check in what folder the texture exists, if it not already is an absolute filename.
Use os.path.join(directory, filename) to join to paths into one. The directories Cinema will use
to search for textures are

1. Document's tex/ folder
2. Document's parent folder
3. User texture folder (use the function)
4. Global texture folders (use the c4d.GetGlobalTexturePath() function)

os.path.isfile() will tell you whether a path is pointing to a file. It'll return False if it's a directory
or if the path does not exist.


On 04/05/2014 at 20:03, xxxxxxxx wrote:

Thanks for the reply Niklas. This is the script that i came up with:

#Get Textures
    def getTextures(self) :
        global texturePathArray
        global Textures
        texturePathArray = []    
        Textures = doc.GetAllTextures()    #Get All textures
        for (i,texture) in Textures:
            if os.path.isfile(texture) == False:
               if os.path.isfile(projectDir + "\" + texture) == True:
                    texturePathArray.append(projectDir + "\" + texture)
               elif os.path.isfile(projectDir + "\ ex" + texture) == True:
                    texturePathArray.append(projectDir + "\ ex" + texture)
               for i in range(8) :
                    if os.path.isfile( + "\" + texture) == True:
                        texturePathArray.append( + "\" + texture)
               for i in range(9) :
                    if os.path.isfile(c4d.GetGlobalTexturePath(i) + "\" + texture) == True:
                        texturePathArray.append(c4d.GetGlobalTexturePath(i) + "\" + texture)

On 05/05/2014 at 17:28, xxxxxxxx wrote:

@harryseow94: Small hint: use os.path.join(...) instead of '+ \", otherwise this does not work on OSX.

Cheers, s_rath

On 05/05/2014 at 20:04, xxxxxxxx wrote:

@s_rath: Cool. i didnt know that till you mentioned it. Thanks.


On 10/02/2015 at 01:58, xxxxxxxx wrote:


I am doing something similar in my script where I want to extract the full path of the textures. I came across this thread which precisely gives me an idea how to go about it. But what I am confused about, is the order in which I should search these paths. E.g. I have a texture water.jpg in tex folder and another water.jpg in one of my search paths. The images are different. My texture contains /searchpath1/water.jpg. But if I start the search in /tex and I get /tex/water.jpg, I stop my search, thus getting the incorrect image path. So how to determine when should I stop my search? Hope I could explain the problem..