OpenMaya.MFileObject Class Reference

Class Description

Manipulate filenames and search paths.
+ Inheritance diagram for OpenMaya.MFileObject:

Public Member Functions

__init__ ()
 
copy ()
 
exists ()
 
expandedFullName ()
 
expandedPath ()
 
fullName ()
 
isSet ()
 
overrideResolvedFullName ()
 
path ()
 
pathCount ()
 
rawFullName ()
 
rawName ()
 
rawPath ()
 
rawURI ()
 
resolvedFullName ()
 
resolvedName ()
 
resolvedPath ()
 
setRawFullName ()
 
setRawName ()
 
setRawPath ()
 
setRawURI ()
 

Static Public Member Functions

getResolvedFullName ()
 
getResolvedFullNameAndExistsStatus ()
 
isAbsolutePath ()
 

Static Public Attributes

int kBaseName = 32
 
int kDirMap = 4
 
int kExact = 2
 
int kInputFile = 54
 
int kInputReference = 62
 
int kNone = 1
 
int kReferenceMappings = 8
 
int kRelative = 16
 
int kStrict = 6
 

Properties

 resolveMethod
 

Constructor & Destructor Documentation

OpenMaya.MFileObject.__init__ ( )
x.__init__(...) initializes x; see help(type(x)) for signature

Member Function Documentation

OpenMaya.MFileObject.copy ( )
copy(source) -> self

Copy data from source file object.

* source (MFileObject) - The source file object to copy from
OpenMaya.MFileObject.exists ( )
exists(index=None) -> bool

Checks to see if the file exists and is readable.
If index is None tests for the fullName file, else tests the file constructed from the indicated portion of the path element and filename element.

* index (int) - Index of the path element to be used in searching for the file.
OpenMaya.MFileObject.expandedFullName ( )
expandedFullName() -> string

Returns the pathname of a file constructed from the unresolved file object values. The file name will consist of the the expanded raw path and raw name elements.
All variables in the path element are expanded, and the first path (the part before the first separator (':') in the path) is prepended to the filename element to construct the fullName.

After expanding environment variables Maya may perform additional modifications to the full file name in order to resolve it to a valid location on disk. This resolved full file name can be accessed through resolvedFullName().
OpenMaya.MFileObject.expandedPath ( )
expandedPath() -> string

Returns the raw path element of the unresolved file object with all environment variables expanded. In the case that the path expands to multiple paths, the first expanded path will be returned.

After expanding environment variables Maya may perform additional modifications to the path in order to resolve it to a valid location on disk. This resolved path can be accessed through resolvedPath().
OpenMaya.MFileObject.fullName ( )
fullName(index) -> string

Returns the pathname of a file constructed from the indicated portion of the path element and filename element.
All variables in the path element are expanded, and the indicated path portion is prepended to the filename element to construct the fullName.

* index (int) - the index of the desired path portion.
OpenMaya.MFileObject.getResolvedFullName ( )
static
getResolvedFullName(rawFullName) -> string

Returns the full path to the resolved file, or an empty string if the resolution was unsuccessful.

* rawFullName (string) - The fully specified unresolved path.
OpenMaya.MFileObject.getResolvedFullNameAndExistsStatus ( )
static
getResolvedFullNameAndExistsStatus(rawFullName, method=kNone) -> (string, bool)

Returns the full path to the resolved file, or an empty string if the resolution was unsuccessful, and a boolean that indicate if the resolved path exists or not.

* rawFullName (string) - The fully specified unresolved path
* resolveMethod (int) - To resolve method to use, default is kNone.

Valid resolve methods:
  kNone                    The resolved path is simply the resulting path after converting
               the raw value to its expanded form. If the path contains environment variables,
               the resolved value will be the first path returned from their expansion.
               Relative paths will be considered to be relative to root of the current project.
               The resolution algorithm will not check if this file actually exists - the
               resolution will be considered successful whether it exists or not.
               With this mode, the resolver will not continue on to attempt to resolve 
               using any other resolve method.
               The user must explicitly check MFileObject.exists() to determine if it is an 
               existing path.
  kExact                   Checks if expanded paths exist. If paths are relative, assume it's relative to
               the current workspace (so check workspace current directory, file-rule directory and
               root directory).
  kDirMap                  Checks path against mappings defined with the dirmap command. Only for absolute paths
  kReferenceMappings       Check path against any previously re-mapped reference locations. If kRelative/kBaseName
               are set, then even if we have an absolute path, convert to relative and/or baseName and
               look for them in directories provided to the missing reference dialog.
  kRelative                Strips away the project directory, and treats path as relative. Relative to the current
               workspace, that is. So look in the workspace current directory, file-rules directory
               and the root directory.
  kBaseName                Strips away everything but the base file name and look in the current workspace,
  kInputFile               This mode is the default on file open and import, and is suitable for 
               files that are to be used as input files.  The file will be checked for 
               existence.
               Combination of kExact, kDirMap, kRelative and kBaseName.
  kInputReference          This mode is the default on file reference. In addition to the checks done for
               a regular input file, it will also check the reference mappings. 
               Combination of kInputFile and kReferenceMappings.
  kStrict                  Combination of kExact and kDirMap.
OpenMaya.MFileObject.isAbsolutePath ( )
static
isAbsolutePath(fileName) -> bool

Checks a file path string and determines if it represents an absolute file path. An absolute path can uniquely identify a directory or file.

* fileName (string) - the string used to check if it is absolute
OpenMaya.MFileObject.isSet ( )
isSet() -> bool

Checks to see if both file and path elements of the file object have been set.
OpenMaya.MFileObject.overrideResolvedFullName ( )
overrideResolvedFullName(fullFileName) -> self

Normally when a raw file name is set, Maya will perform a series of operations on it in an attempt to resolve it to a valid file name. This final resolved file name can be accessed through the resolvedName(), resolvedPath(), and resolvedFullFileName() methods and can be quite different from the originally specified raw file name.

This method will override the normal Maya path resolution process and explicitly set the resolved file name. This path does not have to be a valid file path, but if any '/' characters appear in the given name then the resolved path element of the file object is set to everything in name up to, but not including the last '/'. The resolved filename is set to the part of name after the final '/'.

Once the resolved file name is set, it is only guaranteed to be retained in the file object so long as the raw file path is not updated. Once the rawPath, rawName or rawFullName are set, the normal Maya path resolution process will be re-invoked and the resolved path and filename will be updated.

- fullFileName (string) - the string used to override the path and filename.
OpenMaya.MFileObject.path ( )
path(index) -> string

Returns the indicated portion of the path element of the file object.  All variables in the path element are expanded, and the portion indicated by the argument is extracted and returned.

* index (int) - the index of the desired path portion.
OpenMaya.MFileObject.pathCount ( )
pathCount() -> int

Returns the number of paths in the path element of the file object.
This will be equal to one more than the number of ':' characters specified of the rawPath attribute.
OpenMaya.MFileObject.rawFullName ( )
rawFullName() -> string

Returns the unresolved full file name (path plus filename) of the MFileObject with all environment variables unexpanded.

This method differs from expandedFullName() in that it returns the unexpanded instead of expanded values.
OpenMaya.MFileObject.rawName ( )
rawName() -> string

Returns the unresolved filename element of the MFileObject.
OpenMaya.MFileObject.rawPath ( )
rawPath() -> string

Returns the path element of the MFileObject with all environment variables unexpanded.
OpenMaya.MFileObject.rawURI ( )
rawURI() -> MURI

Returns the unresolved URI of the MFileObject, if any.

This will be empty if the MFileObject was not resolved from a URI.
OpenMaya.MFileObject.resolvedFullName ( )
resolvedFullName() -> string

Returns the first pathname of a file constructed from the path and filename elements.  All variables in the path element are expanded, and the first path (the part before the first ':' in the path) is prepended to the filename element. After expanding all environment     variables Maya may then perform additional modifications, such  as prepending directories to a relative path name, in order to resolve the path to a valid location on disk.

The resolution is performed using the ResolveMethod of the file object.
By default, this will be set to kNone. While this is suitable in many situations, it may not be appropriate if the file is expected to exist.
Refer to getResolvedFullNameAndExistsStatus() for more information about how the  resolution mode is used.

Failure to resolve the path according to the specifications of the file object will result in an empty return value.
OpenMaya.MFileObject.resolvedName ( )
resolvedName() -> string

Returns the resolved filename element of the file object.
OpenMaya.MFileObject.resolvedPath ( )
resolvedPath() -> string

Returns the resolved path element of the file object. In order to build the resolved path, Maya first expands all environment variables and then may perform additional modifications, such as prepending directories to a relative path name, in order to resolve the path to a valid location on disk.
OpenMaya.MFileObject.setRawFullName ( )
setRawFullName(fullFileName) -> self

This method combines the functions of the setRawName and setRawPath methods in that it sets both the path and filename from the given name.

If any '/' characters appear in the given name then the path element of the MFileObject is set to everything in name up to, but not including the last '/'.  The filename is set to the part of name after the final '/'.

If no '/' characters appear in the given name then the path element is set to "." and the filename is set to the given name.

Note that if the specified fullFileName is relative, contains environment variables, or does not exist, the full names returned by resolvedFullName() and expandedFullName() may not match the fullFileName. See the description of resolvedFullName() and expandedFullName() for more information.

Also note that for URI-based file paths (e.g. "arrow:uri_path_to_file"),  setRawFullName will not call setRawName and setRawPath (raw name and path will remain empty). Use resolvedName and resolvedPath to retrieve the resolved file path, or rawFullName to retrieve the unresolved file path.

* fullFileName (string) - The string used to initialize the path and filename.
OpenMaya.MFileObject.setRawName ( )
setRawName(fileName) -> self

Set the unresolved filename element of the MFileObject instance.  This name should not contain any '/' characters, it should indicate simply the name of a file.  The directories in which this name will be searched for are specified by setRawPath.

* fileName (string) - The filename to set.
OpenMaya.MFileObject.setRawPath ( )
setRawPath(pathName) -> self

Set the unresolved path element of the MFileObject instance.  This should contain a list of directories, each separated by a single ':' character.  The pathnames can contain Unix environment variables in the form $VARNAME.  These will be expanded when paths to actual filenames are constructed.

Note that if the specified pathName is relative, contains environment variables, or does not exist, the paths returned by resolvedPath() and expandedPath() may not match the rawPath. See the description of resolvedPath() and expandedPath() for more information.

* pathName (string) - The path string.
OpenMaya.MFileObject.setRawURI ( )
setRawURI(uri) -> self

Set the unresolved URI of the MFileObject instance.

* uri (string or MURI) - The unresolved URI.

Property Documentation

OpenMaya.MFileObject.resolveMethod
static
 The file-path resolution steps this file object will use.