Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Path to res folder on Mac [SOLVED]

    SDK Help
    0
    7
    741
    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
      Helper
      last edited by

      On 24/09/2015 at 02:34, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   17 
      Platform:      Mac OSX  ; 
      Language(s) :     C++  ;

      ---------
      Hi,

      I am trying to access the res folder, and a subfolder inside it where I have some images stored.
      On windows, I can access the folder with the images without a problem, using this code:

      String imageTexture = "myImage.jpg";
      String ss = GeGetPluginPath().GetString()+"\\res\\"+"\\images\\"+imageTexture;
      

      On Xcode 7, it does not work. It gives this result in the material editor:
      Asset not found. 
        Cause: file:///Applications/MAXON/CINEMA 4D R17/plugins/MyPlugin\res\\images\myImage.jpg 
        Cause: Errno #2: No such file or directory
      Note the backslashes, they need to be forward slashes, but I can't figure out how to do this on the Mac.
      Any help on this would be appreciated.
      Thanks

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

        On 24/09/2015 at 03:13, xxxxxxxx wrote:

        1. Why not avoid the double backslash:

        String ss = GeGetPluginPath().GetString()+"\\res\\images\\"+imageTexture;
        

        2. I use #defines to distinguish the OS for which my plugin is being built.

        #ifdef _WINDOWS
        String ss = GeGetPluginPath().GetString()+"\\res\\images\\"+imageTexture;
        #else // or #elif defined(MACOS) or similar
        String ss = GeGetPluginPath().GetString()+"/res/images/"+imageTexture;
        #endif
        
        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          On 24/09/2015 at 04:00, xxxxxxxx wrote:

          Thanks for the reply Robert.

          I already tried that (and a million other alterations). With your code, all I get is the path without the name of the plugin nor the folders:

          Asset not found. 
            Cause: file:///Applications/MAXON/CINEMA 4D R17/plugins/myImage.jpg 
            Cause: Errno #2: No such file or directory

          If I print the result with GePrint, I get the proper path. But inside the material editor the result is wrong and the file is not found.

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

            On 24/09/2015 at 04:12, xxxxxxxx wrote:

            When you create the Filename, you will probably be better using SetDirectory() and SetFile().  It is a quirk of this class that has always bothered me.  So, create the directory path string and use it with SetDirectory() and then use SetFile() with the file name.  Both of these methods accept Filename, so you will need to call something like:

            filename.SetDirectory(Filename(ss)); // without imageTexture appended
            filename.SetFile(Filename(imageTexture));
            

            It may also be a better idea to simply avoid the '' and '/' and append to the directory path as follows:

            Filename ss = GeGetPluginPath() + Filename("res") + Filename("images");
            

            In this case, the path separators are handled by the underlying system,

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

              On 24/09/2015 at 10:44, xxxxxxxx wrote:

              Thank you Robert. It now works.

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

                On 25/09/2015 at 08:46, xxxxxxxx wrote:

                Hi guys,

                nice, that you already solved this on your own 🙂
                Just a small addition from my side: I'd suggest to use only slashes (/) in filepaths in your plugins code. C4D will take care and convert them to backslashes on Windows systems. Contrary backslashes (\ or rather \\) won't be converted into slashes on Mac systems. So with slashes it is a bit easier to write system independent code.

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

                  On 25/09/2015 at 08:58, xxxxxxxx wrote:

                  Originally posted by xxxxxxxx

                  Hi guys,
                  nice, that you already solved this on your own 🙂
                  Just a small addition from my side: I'd suggest to use only slashes (/) in filepaths in your plugins code. C4D will take care and convert them to backslashes on Windows systems. Contrary backslashes (\ or rather \\) won't be converted into slashes on Mac systems. So with slashes it is a bit easier to write system independent code.

                  Just to give you some background info why there 's only limited conversion (on the Mac), folks:

                  In the Win32 file system API there are a lot of limitations regarding what file names can contain (there are a lot less on the NT system level - that 's more like a unix based file system - but you don't get that on the Win32 level due to backward compatibility).

                  On Unix file systems (like on OS X and Linux) on the other hand there are basically just two limitations for a valid file name: It can't use a slash and it can't use a null byte. All the other stuff (":", "\", ...) is possible in a file name on the posix level - and is used by customers in their content.

                  Best regards,

                  Wilfried

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