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
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Global variable for Preferences Folder?

    Cinema 4D SDK
    r21 python
    3
    7
    623
    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.
    • B
      bentraje
      last edited by

      Hi,

      Is there a global variable for preferences folder where it automatically retrieves the path of the preferences?

      Currently, I have it hard coded like in the following, but it would be nice a fail-safe of doing it (i.e. global variable).

      def open_folder(path=r'C:\Users\Luke\AppData\Roaming\MAXON\Maxon Cinema 4D R21_64C2B3BD\plugins'): 
          webbrowser.open('file:///' + path)
      
      1 Reply Last reply Reply Quote 0
      • B
        bentraje
        last edited by

        Lol. Ignore this. Just when I was writing this, stumbled upon the documentation that solves my problem.

        Here is the method.
        c4d.storage.GeGetStartupWritePath()

        C4DSC 1 Reply Last reply Reply Quote 0
        • C4DSC
          C4DS @bentraje
          last edited by

          @bentraje
          Since you're looking for the plugins folder it might be advised to use GeGetPluginPath instead?

          1 Reply Last reply Reply Quote 1
          • B
            bentraje
            last edited by

            @C4DS said in Global variable for Preferences Folder?:

            GeGetPluginPath

            Unfortunately, it returns me the following path C:\\Program Files\\Maxon Cinema 4D R21\\corelibs'.
            No worries, I just did the os.path.join(path, "plugins") and it works as expected.

            C4DSC 1 Reply Last reply Reply Quote 0
            • C4DSC
              C4DS @bentraje
              last edited by C4DS

              @bentraje said in Global variable for Preferences Folder?:

              Unfortunately, it returns me the following path C:\\Program Files\\Maxon Cinema 4D R21\\corelibs'.

              I am using the GeGetPluginPath alot in my C++ plugins, but the Python SDK documentation mentions:

              Warning
              
              The Python implementation is different from the C++. In the Python SDK, this function returns the path of the Python SDK module. To get the path of your Python plugin use __file__. 
              

              Also note that from R21 (or was it R20) the user can define his/her own path(s) for plugins.
              In that case you'll end up with a possibly non-existing path if you simply concatenate "plugins" to the startup-write path.

              1 Reply Last reply Reply Quote 1
              • B
                bentraje
                last edited by

                Ah gotcha. Thanks for the heads up! 🙂

                1 Reply Last reply Reply Quote 0
                • ferdinandF
                  ferdinand
                  last edited by ferdinand

                  Hi @bentraje, hi @C4DS,

                  you seem to have solved your problem yourself, so there is not much for me to add here apart from offering alternative solutions. One slightly dodgy way to get the preferences path is to use the path which is stored under c4d.PREF_MEMORY_PVHARDFOLDER in the world container of Cinema (it is the Memory>Cache Path attribute).

                  A more elegant way is to use maxon.Application.GetUrl() which does properly handle the different paths under which the preferences can be stored (see example at the end of my posting for details).

                  Cheers,
                  Ferdinand

                  """On how to iterate over the different  preferences paths with the maxon API.
                  """
                  
                  import maxon
                  
                  def main():
                      """Entry point.
                      """
                      for urlType in (maxon.APPLICATION_URLTYPE.GLOBALPREFS_DIR,
                                      maxon.APPLICATION_URLTYPE.PREFS_DIR,
                                      maxon.APPLICATION_URLTYPE.PREFS_DIR_STATIC):
                          print (f"{urlType}:{maxon.Application.GetUrl(urlType)}")
                      
                  if __name__=='__main__':
                      main()
                  
                  

                  MAXON SDK Specialist
                  developers.maxon.net

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