Getting the full pathname of a bitmap
-
On 28/04/2014 at 15:00, xxxxxxxx wrote:
I'm getting the bitmap filename from a color channel of a material with c4d.BITMAPSHADER_FILENAME
When the bitmap is in any of the default search paths, I only get a filename. For example, stripes.jpg
But the file stripes.jpg could be in doc_folder/tex or simply in doc_folder, or in Cinema 4D folder or in C4D folder, inside a tex folder, or inside the prefs folder or inside the prefs folder, inside a tex folder, etc.
All of these are default search paths.
But getting the filename is not enough for me because I need to access the file to, for example, duplicate it inside another folder.
So, how can I get a full pathname for any bitmap that is inside the color channel, even if the bitmap is inside any of the default search paths?
Must I check for all of them? -
On 28/04/2014 at 15:45, xxxxxxxx wrote:
Well, just coded some code that seems to work fine.
I check to see if the filename is simply a filename or a full path with:
if filename == os.path.basename(filename) :
And, if it is a simple filename, I reconstruct the full path name with:
def GetFullPath(doc,filename) : # check for doc_folder/filename full_path=os.path.join(doc.GetDocumentPath(),filename) if os.path.exists(full_path) :return full_path # check for doc_folder/tex/filename full_path=os.path.join(doc.GetDocumentPath(),"tex",filename) if os.path.exists(full_path) :return full_path # check for app_folder/filename tex_path,dummy=os.path.split(c4d.storage.GeGetStartupApplication()) full_path=os.path.join(tex_path,filename) if os.path.exists(full_path) :return full_path # check for app_folder/tex/filename full_path=os.path.join(tex_path,"tex",filename) if os.path.exists(full_path) :return full_path # check for prefs_folder/filename tex_path=c4d.storage.GeGetC4DPath(c4d.C4D_PATH_PREFS) full_path=os.path.join(tex_path,filename) if os.path.exists(full_path) :return full_path # check for prefs_folder/tex/filename full_path=os.path.join(tex_path,"tex",filename) if os.path.exists(full_path) :return full_path for i in range(10) : tex_path=c4d.GetGlobalTexturePath(i) if tex_path != "": full_path=os.path.join(tex_path,filename) if os.path.exists(full_path) :return full_path return filename
-
On 02/05/2014 at 06:24, xxxxxxxx wrote:
Funny someone asked the same question few days later. Didn't see yours before.
[URL-REMOVED]
-Niklas
[URL-REMOVED] @maxon: This section contained a non-resolving link which has been removed.