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 =/

EDIT:
I found this:
pm.system.Workspace().getPath()
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:
pm.system.sceneName().getProject()

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:
pm.sceneName().parent.parent
I think that should work just fine.

Thanks!

1 Like