Help with importing .mb relative path


#1

hi i use this site a lot when im stuck but couldn’t find an answer to this but sorry if its been asked before it seems simple.
Is there a way to use mel script to load a .mb file but relative to the mel script file, so its in the same folder on a different computer it would still work? Thanks in advance


#2

not mel but this should work (python).

import maya.cmds as mc
import os

newFileName = 'testFile.mb'

newFilePath = os.path.join(os.path.split(mc.file(q=True, loc=True))[0], newFileName)
mc.file(filePath, o=True)

Thinking bout it there should be a simpler way, will have a butchers.


#3

if the mel script is already on the MAYA_SCRIPT_PATH, like in “My Documents/maya/2012/scripts”, then you can get the path to the MEL script using “whatIs”.

for example:

whatIs “myMelScript.mel”;

returns the path to the script file.


#4

ah i mis-read. cheers.


#5

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.