PyMEL: question about path object

Hi. I’m trying to do more in PyMEL and am looking into using path objects, but I’m unsure of how to work with it.
For instance, I want to get the sourceimages folder path to the current scene. I could do it with Python’s os module, but I would really like to learn how to do it in PyMEL if possible. I haven’t been able to find out just how, yet.

So basically I want this:

  1. get the project path to the current scene, this returns a python path.
  2. then from there, get the source images folder path

However I can’t seem to find what I need.
I have this:
scenePath = pm.system.sceneName()

and it returns a PyMEL path object to the scene file.
And I could use this and partition at “scenes/” getting scenePath[0] and scenePath[-1], but then I lose the path object and am back to just going with os module =/

I found this:
and it does give me the project folder, but only if it has been set correctly.
It’s imperative that it relies on the scene file that is opened. I don’t want it to rely on the user to have to set the project directory, if possible.

I’m thinking I want something like:

TLDR: how can I get the file path of the currently opened scene file, in PyMEL without using Python’s os module?

What exactly is the problem with using the os module?
If you can get most of the information from pm.sceneName(), just derive the rest of it with os.path.

1 Like

Nothing really, I just wanted to learn to do it in PyMEL.
I found this:
I think that should work just fine.


1 Like