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

    LoadDialog - restricting what users can choose

    Scheduled Pinned Locked Moved PYTHON Development
    5 Posts 0 Posters 415 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 13/11/2013 at 07:29, xxxxxxxx wrote:

      I'm trying to load a bitmap file to use in a material.  What do the flags for the c4d.Storage.LoadDialog do?  Reading the documentation I was under the impression that it would restrict the users selection to the flag.  Do I have to test to see if the user chose an image using another method?

      fn = c4d.storage.LoadDialog(c4d.FILESELECTTYPE_IMAGES)

      thanks for any advice.

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

        On 13/11/2013 at 07:53, xxxxxxxx wrote:

        Hi .del,

        technically any file can be an image file. If you really want to make sure a file is actually a bitmap, you
        can load it before assigning to a material and see if it loaded successfully. See BaseBitmap.InitWith().

        I can't confirm it for Windows now, but the type parameter to the LoadDialog() function does not seem
        to have an affect on Mac OS. You're better of performing a check if necessary.

        Best,
        -Niklas

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

          On 13/11/2013 at 08:05, xxxxxxxx wrote:

          Thanks Niklas.  I'm heading down that path right now.  Any ideas how to make a file path relative?  Do I need to pull the filename out of the path or is there a function lurking some where?  Our project files get moved around on occasion and I want to be sure the texture paths are relative.

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

            On 13/11/2013 at 08:14, xxxxxxxx wrote:

            The os.path module contains functions for working with filesystem paths. Using os.path.relpath, you can
            make one path relative to another path (assuming the path is contained in the specified directory).

            > path = c4d.storage.LoadDialog()
            > if not path: return
            > path = os.path.relpath(path, doc.GetDocumentPath())

            Best,
            -Niklas

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

              On 13/11/2013 at 08:21, xxxxxxxx wrote:

              Thanks again.  I'm new at Python and have been working mainly with the c4d documentation.  I have a python book and will check that out for more info on the os.path.

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