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

    Load file from plugin directory

    Cinema 4D SDK
    python sdk
    3
    4
    777
    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.
    • G
      gsmetzer
      last edited by Manuel

      Ok, I'm developing a tag plugin and I have specific splineData stored in a hyperfile that the tag needs to load when starting.
      This works fine on my own computer:

      path = os.path.join("/Applications","thedrive","Dropbox","INTERNAL","MyTag","SPLINEDATA")
      

      but if I want to give the plugin to a co-worker or sell it how do I create the path? Am I able to put the splineData file in my plugin's /res folder and load it from there? What would that code look like?
      I can't seem to find a standard python example that works for this.
      Thank you for any insight.

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

        Hi,

        I don't know where you are planning to store your data, but remember that the constant __file__ in Python holds the file path of the currently interpreted script. So os.path.join(os.path.split(__file__)[0], "splinedata") for example would point to a folder called "splinedata" in your plugin directory, no matter where the plugin folder lies (assuming the python file lies on the top level).

        You can also get the 'important' c4d paths via c4d.storage.GeGetC4DPath().

        Cheers
        zipit

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 2
        • G
          gsmetzer
          last edited by

          @zipit said in Load file from plugin directory:

          os.path.join(os.path.split(file)[0], "splinedata")

          Amazing, that's works perfectly. Thank you!

          1 Reply Last reply Reply Quote 0
          • ManuelM
            Manuel
            last edited by

            hello,

            @zipit thanks for your answer.

            for your next threads, please help us keeping things organised and clean. I know it's not your priority but it really simplify our work here.

            • Q&A New Functionality.
            • How to Post Questions especially the tagging part.

            I've added the tags and marked this thread as a question so when you considered it as solved, please change the state 🙂

            In the python help, you have a link to github where you can find examples.
            https://github.com/PluginCafe/cinema4d_py_sdk

            you will see sometimes in those example this code :

                path, fn = os.path.split(__file__)
                bmp = bitmaps.BaseBitmap()
                bmp.InitWith(os.path.join(path, "res", "gravitation.tif"))
            

            Just to add a few words about c4d.storage.GeGetC4DPath() That's the classic API.

            In c++ with the maxon API you have GetUrl

            In Python, in r20 symbol are not set and if you want to retrieve the resource directory it will return the Cinema4D's one and not your plugin's one.

            Cheers
            Manuel

            MAXON SDK Specialist

            MAXON Registered Developer

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