Esempio n. 1
0
def export(exportList=None,
           fileName='',
           path='',
           prefix='',
           suffix='',
           format=''):
    """ Export only the selection if it is passed as argument or the complete scene with references"""
    if not fileName:
        fileName = os.path.basename(cmds.file(query=True,
                                              sceneName=True)) or 'nosave'
    filePath = libpython.formatPath(fileName, path, prefix, suffix)
    if exportList:
        cmds.select(exportList, noExpand=True)
    if not format:
        format = libpython.getFirstItem(cmds.file(type=True,
                                                  query=True)) or 'mayaAscii'
    # Export references only if is on Export All mode
    finalPath = cmds.file(filePath,
                          force=True,
                          options="v=0;",
                          type=format,
                          preserveReferences=not bool(exportList),
                          exportUnloadedReferences=not bool(exportList),
                          exportSelected=bool(exportList),
                          exportAll=not bool(exportList),
                          shader=True,
                          channels=True,
                          constructionHistory=True,
                          constraints=True,
                          expressions=True)
    return finalPath
Esempio n. 2
0
def getTransform(shape, fullPath=True):
    """Return the transform of the shape in argument"""
    transforms = ''
    if not isinstance(shape, basestring):
        logger.error('Input not valid. Expecting a string shape, got "%s": %s' % (type(shape).__name__, shape))
    elif 'transform' != cmds.nodeType(shape):
        transforms = cmds.listRelatives(shape, fullPath=fullPath, parent=True)
        transform = libpython.getFirstItem(transforms, '')
    return transform
Esempio n. 3
0
def getTransform(shape, fullPath=True):
    """Return the transform of the shape in argument"""
    transforms = ''
    if not isinstance(shape, basestring):
        logger.error(
            'Input not valid. Expecting a string shape, got "%s": %s' %
            (type(shape).__name__, shape))
    elif 'transform' != cmds.nodeType(shape):
        transforms = cmds.listRelatives(shape, fullPath=fullPath, parent=True)
        transform = libpython.getFirstItem(transforms, '')
    return transform
Esempio n. 4
0
def export(exportList=None, fileName='', path='', prefix='', suffix='', format=''):
    """ Export only the selection if it is passed as argument or the complete scene with references"""
    if not fileName:
        fileName = os.path.basename(cmds.file(query=True, sceneName=True)) or 'nosave'
    filePath = libpython.formatPath(fileName, path, prefix, suffix)
    if exportList:
        cmds.select(exportList, noExpand=True)
    if not format:
        format = libpython.getFirstItem(cmds.file(type=True, query=True)) or 'mayaAscii'
    # Export references only if is on Export All mode
    finalPath = cmds.file(filePath, force=True, options="v=0;", type=format, preserveReferences=not bool(exportList), exportUnloadedReferences=not bool(exportList), exportSelected=bool(exportList), exportAll=not bool(exportList), shader=True, channels=True, constructionHistory=True, constraints=True, expressions=True)
    return finalPath
Esempio n. 5
0
def isVisible(node):
    visible = False
    try:
        visible = cmds.getAttr(node + '.visibility')
        visible = visible and not cmds.getAttr(node + '.intermediateObject')
    except ValueError:
        pass
    try:
        visible = visible and cmds.getAttr(node + '.overrideVisibility')
    except ValueError:
        pass
    if visible:
        parents = cmds.listRelatives(node, parent=True, path=True)
        if parents:
            visible = isVisible(libpython.getFirstItem(parents))
    return visible
Esempio n. 6
0
def isVisible(node):
    visible = False
    try:
        visible = cmds.getAttr(node + '.visibility')
        visible = visible and not cmds.getAttr(node + '.intermediateObject')
    except ValueError:
        pass
    try:
        visible = visible and cmds.getAttr(node + '.overrideVisibility')
    except ValueError:
        pass
    if visible:
        parents = cmds.listRelatives(node, parent=True, path=True)
        if parents:
            visible = isVisible(libpython.getFirstItem(parents))
    return visible
Esempio n. 7
0
def getFirstSelection(filterNb=None, longName=False):
    """Get the first item in the selection"""
    selection = cmds.ls(selection=True, long=longName)
    if filterNb and selection:
        selection = cmds.filterExpand(selection, sm=filterNb)
    return libpython.getFirstItem(selection, '')
Esempio n. 8
0
def getFirstSelection(filterNb=None, longName=False):
    """Get the first item in the selection"""
    selection = cmds.ls(selection=True, long=longName)
    if filterNb and selection:
        selection = cmds.filterExpand(selection, sm=filterNb)
    return libpython.getFirstItem(selection, '')