Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Recent
    • Tags
    • Users
    • Login

    Getting the full pathname of a bitmap

    Scheduled Pinned Locked Moved PYTHON Development
    3 Posts 0 Posters 235 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      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?

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        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   
        
        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          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.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post