LoadDialog - restricting what users can choose
-
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.
-
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 -
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.
-
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 -
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.