AM Tools 1.05
Functions | Variables
Package amTools.utilities.files

Utility functions for working with files. More...

Functions

def convertValidTypesToStringList
 Convert an incoming object (oldList) into a list of strings made of only those objects permitted by the validTypes filter.
def find
 Find files in sourcePath that match certain patterns supplied via keywords.
def copyDirectoryStructure
 Copy a directory structure from one location into another location.
def removeFlagArgPairFromUIConfigurationScript
 Remove a specified flag from a line in a uiConfigurationScriptNode string in a .ma file.
def patchMayaAsciiFile
 Patch a Maya Ascii file to attempt to make it backward compatible as far as 8.5.
def batchExport
 Batch export files in one location to another location.

Variables

list kUIConfigFlags2011
 UI configuration flags invalid before Maya 2011.
list kUIConfigFlags2009
 UI configuration flags invalid before Maya 2009.
list kUIConfigFlags2008
 UI configuration flags invalid before Maya 2008.

Detailed Description

Utility functions for working with files.

Many functions are primarily intended to be executed from batch mode.

WARNING:
This module has not been extensively tested. I cobbled a lot of these functions together for a project I needed, and it got the job done, but I make no claims that any of the batching functions are bulletproof by any stretch (or even well-designed). I haven't reused a lot of these functions since then, so please do send me any feedback regarding your experiences!

Creation Info:

Donations: http://adammechtley.com/donations/

License: The MIT License

Copyright (c) 2011 Adam Mechtley (http://adammechtley.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


Function Documentation

def amTools.utilities.files.batchExport (   sourcePath,
  destPath,
  toFileType = 'fbx',
  recursively = True,
  matchDirectorySructure = True,
  keywords 
)

Batch export files in one location to another location.

Returns True on success. Only intended for use in standalone mode; otherwise FBX settings are not respected. Not all FBX Export settings are currently supported. Not all versions of Maya have been completely tested; please tell me if you find errors in old versions.

Parameters:
filePatternsList corresponding to different file extensions to parse
filterPrefixList corresponding to required prefixes in file names
filterSuffixList corresponding to required suffixes in file names
filterContainsList corresponding to required string in file names
addPrefixString to prefix on all exported files
addSuffixString to suffix on all exported files
bakeAllString specifying object types on which to bake animation
bakeAllRangeTuple or list specifying a frame range
maVersionVersion of Maya to set for .ma exports
fbxVersionFBXFileVersion string
fbxAsciiFBXExportInAscii
fbxBakeFBXExportBakeComplexAnimation boolean
fbxBakeStartFBXExportBakeComplexStart float
fbxBakeEndFBXExportBakeComplexEnd
fbxAnimOnlyFBXExportAnimationOnly boolean
fbxConstraintsFBXExportConstraints boolean
fbxUnitFBXConvertUnitString and FBXExportConvertUnitString
fbxUpAxisFBXExportUpAxis
fbxAxisConvertFBXExportAxisConversionMethod
fbxScaleFBXExportScaleFactor
def amTools.utilities.files.convertValidTypesToStringList (   oldList = [],
  validTypes = [types.StringTypes] 
)

Convert an incoming object (oldList) into a list of strings made of only those objects permitted by the validTypes filter.

def amTools.utilities.files.copyDirectoryStructure (   sourcePath,
  destPath,
  includeHidden = False 
)

Copy a directory structure from one location into another location.

Returns True on success.

def amTools.utilities.files.find (   sourcePath,
  recursively = True,
  includeHidden = False,
  keywords 
)

Find files in sourcePath that match certain patterns supplied via keywords.

Hidden file detection is not implemented for Windows. Sorry, but I just don't care.

Parameters:
foldersBoolean specifying that the caller wants a list of folders rather than files
pathsString specifying how paths should be returned with respect to sourcePath: full, relative, or no
filePatternsList corresponding to different file extensions to parse
filterPrefixList corresponding to required prefixes in file names
filterSuffixList corresponding to required suffixes in file names
filterContainsList corresponding to required string in file names
def amTools.utilities.files.patchMayaAsciiFile (   file,
  toVersion 
)

Patch a Maya Ascii file to attempt to make it backward compatible as far as 8.5.

This function will bake animation layers for old versions of Maya and remove other invalid requirements, flags, etc. Not all compatibility is presumed to be fixed; please use at your own risk.

def amTools.utilities.files.removeFlagArgPairFromUIConfigurationScript (   line,
  flag 
)

Remove a specified flag from a line in a uiConfigurationScriptNode string in a .ma file.


Variable Documentation

Initial value:
00001 [
00002         '-jointXray',
00003         '-activeComponentsXray',
00004         '-lineWidth',
00005         '-shadingModel']

UI configuration flags invalid before Maya 2008.

Initial value:
00001 [
00002         '-nParticles',
00003         '-organizeByLayer',
00004         '-showAnimLayerWeight',
00005         '-autoExpandLayers',
00006         '-showAssets',
00007         '-showContainedOnly',
00008         '-showPublishedAsConnected',
00009         '-showContainerContents',
00010         '-containersIgnoreFilters',
00011         '-animLayerFilterOptions',
00012         '-constrainDrag',
00013         '-mergeConnections',
00014         '-showRelationships',
00015         '-opaqueContainers',
00016         '-heatMapDisplay',
00017         '-range']

UI configuration flags invalid before Maya 2009.

Initial value:
00001 [
00002         '-ignorePanZoom',
00003         '-showUpstreamCurves',
00004         '-showPinIcons',
00005         '-showStackedCurves',
00006         '-stackedCurves',
00007         '-stackedCurvesMin',
00008         '-stackedCurvesMax',
00009         '-stackedCurvesSpace',
00010         '-displayNormalized',
00011         '-preSelectionHighlight',
00012         '-manageSequencer']

UI configuration flags invalid before Maya 2011.

 All Classes Namespaces Files Functions Variables