Пример #1
0
    def getSelectedTokenUid(self):
        """ This returns the URL of the currently selected token, or None. """

        conn   = nimble.getConnection()
        result = conn.runPythonModule(GetSelectedUidList, runInMaya=True)

        # Check to see if the remote command execution was successful
        if not result.success:
            PyGlassBasicDialogManager.openOk(
                self,
                'Failed UID Query',
                'Unable to get selected UID list from Maya',
                'Error')
            return None

        selectedUidList = result.payload['selectedUidList']
        if len(selectedUidList) == 0:
            return None

        # check to see if it really is a proxy or token that was selected
        uid = selectedUidList[0]
        if uid.endswith('_proxy') or uid.endswith('_token'):
            return uid
        else:
            return None
Пример #2
0
    def getSelectedTracks(self):
        """ This returns a list of track model instances corresponding to the
            track nodes that are currently selected.  To achieve this, it first
            runs a remote script to get a list of track UIDs from the selected
            Maya track nodes. A list of the corresponding track models is then
            returned. """

        conn   = nimble.getConnection()
        result = conn.runPythonModule(GetSelectedUidList, runInMaya=True )

        # Check to see if the remote command execution was successful
        if not result.success:
            PyGlassBasicDialogManager.openOk(
                self,
                'Failed UID Query',
                'Unable to get selected UID list from Maya',
                'Error')
            return None

        # from this UID list, create the corresponding track list
        selectedUidList = result.payload['selectedUidList']
        if len(selectedUidList) == 0:
            return None

        tracks = list()
        for uid in selectedUidList:
            track = self.getTrackByUid(uid)
            if track:
                track.updateFromNode()
                tracks.append(track)
        return tracks
Пример #3
0
    def getSelectedTokenUids(self):
        """ This returns a list of URL of the currently selected tokens, or
            None. """

        conn   = nimble.getConnection()
        result = conn.runPythonModule(GetSelectedUidList, runInMaya=True)

        # Check to see if the remote command execution was successful
        if not result.success:
            PyGlassBasicDialogManager.openOk(
                self,
                'Failed UID Query',
                'Unable to get selected UID list from Maya',
                'Error')
            return None

        selectedUidList = result.payload['selectedUidList']
        if len(selectedUidList) == 0:
            return None

        # return those UIDs corresponding to proxies or tokens
        tokenUidList = list()
        for uid in selectedUidList:
            if uid.endswith('_proxy') or uid.endswith('_token'):
                tokenUidList.append(uid)

        return tokenUidList
Пример #4
0
    def __init__(self, parent, **kwargs):
        """Creates a new instance of AlloyHomeWidget."""
        PyGlassWidget.__init__(self, parent, widgetFile=False, **kwargs)

        try:
            conn = nimble.getConnection()
        except Exception, err:
            pass
Пример #5
0
    def deleteTokens(self):
        """ This sets the attributes in the Maya token based on the properties
            of the props dictionary that is passed. """

        conn   = nimble.getConnection()
        result = conn.runPythonModule(DeleteTokens, runInMaya=True)

        return result.success
Пример #6
0
def render(directory=None, name=None, flags=None):
    """
    Renders the current scene and saves the result to an image file
    """

    conn = nimble.getConnection()

    return conn.runPythonClass(RenderScene,
                               name=name,
                               directory=directory,
                               render_flags=flags)
Пример #7
0
    def setTokenProps(self, uid, props):
        """ This sets the attributes in the Maya token based on the properties
            of the props dictionary that is passed. """

        conn   = nimble.getConnection()
        result = conn.runPythonModule(
            UpdateToken,
            uid=uid,
            props=props,
            runInMaya=True)

        return result.success
Пример #8
0
 def _handleInitializeSceneClick(self):
     conn   = nimble.getConnection()
     result = conn.runPythonModule(InitializeTrackwayScene)
     if not result.success:
         header = u'Failed'
         message = u'Unable to initialize your Maya scene'
         PyGlassBasicDialogManager.openOk(
             self.mainWindow,
             header,
             message,
             u'Initialize Scene')
     self._iniBtn.setText(u'Reinitialize')
Пример #9
0
    def getTokenProps(self, uid):
        """ This returns a dictionary of properties from the Maya token
            specified by the uid, or an error if it does not exist.  This
            function treats a token and a track node as equivalent. """

        conn   = nimble.getConnection()
        result = conn.runPythonModule(GetTokenProps, uid=uid, runInMaya=True)

        if result.payload.get('error'):
            print('Error in getTokenProps:', result.payload.get('message'))
            return False

        return result.payload.get('props')
Пример #10
0
    def createTokens(self, propsList):
        """ Create tokens in Maya, each based on the properties specified by a
            corresponding dictionary props within the list propsList. """

        conn   = nimble.getConnection()
        result = conn.runPythonModule(
            CreateTokens,
            propsList=propsList,
            runInMaya=True)

        if result.payload.get('error'):
            print('Error in createTokens:', result.payload.get('message'))
            return False
Пример #11
0
def render(directory=None, name=None, flags=None):
    """
    Renders the current scene and saves the result to an image file
    """

    conn = nimble.getConnection()

    return conn.runPythonClass(
        RenderScene,
        name=name,
        directory=directory,
        render_flags=flags
    )
Пример #12
0
    def createToken(self, props):
        """ Create a token in Maya, using the uid and properties specified in
            the dictionary props. """

        conn   = nimble.getConnection()
        result = conn.runPythonModule(
            CreateToken,
            uid=props['uid'],
            props=props,
            runInMaya=True)

        if result.payload.get('error'):
            print('Error in createToken:', result.payload.get('message'))
            return False
Пример #13
0
    def updateNode(self):
        """ Sends values to Maya nodeName representation of the track to
            synchronize the values in the model and the nodeName. """

        conn   = nimble.getConnection()
        result = conn.runPythonModule(
            UpdateTrackNode,
            uid=self.uid,
            props=self.toMayaNodeDict(),
            runInMaya=True)
        if not result.success:
            return False

        self.nodeName = result.payload.get('nodeName')
        return True
Пример #14
0
    def getTokenNodeName(self, uid):
        """ This gets the name of the token (i.e., the string name of the
            transform node for a specified UID string). It returns None if that
            token is not found. """

        # if asking for nothing, then get nothing in return
        if uid is None:
            return None

        conn   = nimble.getConnection()
        result = conn.runPythonModule(GetTokenProps, uid=uid, runInMaya=True)

        if result.payload.get('error'):
            print('Error in getTokenNodeName:', result.payload.get('message'))
            return False

        return result.payload.get('nodeName')
Пример #15
0
    def getUidList(self):
        """ Returns a list of the UIDs of all track nodes currently loaded into
            Maya. """

        conn   = nimble.getConnection()

        result = conn.runPythonModule(GetUidList, runInMaya=True)

        # and check to see if the remote command execution was successful
        if not result.success:
            PyGlassBasicDialogManager.openOk(
                parent=self,
                header='ERROR',
                message='Unable to get UID list from Maya')
            self.closeSession()
            return None

        self.closeSession()
        return result.payload['uidList']
Пример #16
0
def pingTest():

    from pyaid.string.StringUtils import StringUtils

    import nimble

    nimble.changeKeepAlive(keepAlive)

    conn = nimble.getConnection()

    #-----------------------------------------------------------------------------------------------
    # PING
    #       An empty call that tests that the Nimble connection is able to complete a request and
    #       response loop and prints the response object when complete.
    for i in range(iterations):
        result = conn.ping()
        if not runSilent:
            print(u'PING:', result.echo(True, True))

    #-----------------------------------------------------------------------------------------------
    # ECHO
    #       A basic call that sends an echo message, which the remote Nimble server returns in the
    #       response. Confirms that data can be set, read, and returned through the Nimble
    #       connection.
    smallMessage = 'This is a test'
    for i in range(iterations):
        result = conn.echo(smallMessage)
        if not runSilent:
            print(u'ECHO:', result.echo(True, True))

    #-----------------------------------------------------------------------------------------------
    # LONG ECHO
    #       A repeat of the echo test, but with a very long echo message that tests the ability for
    #       the Nimble socket protocols to chunk and stream large messages without losing data. The
    #       test is also repeated numerous times to confirm that the nimble socket connection
    #       survives through high-intensity multi-stage communication.
    largeMessage = StringUtils.getRandomString(64000)
    for i in range(iterations):
        result = conn.echo(largeMessage)
        if not runSilent:
            print(u'LARGE ECHO[#%s]:' % i, result.echo(True, True))

    print(u'\nTests Complete')
Пример #17
0
def pingTest():

    from pyaid.string.StringUtils import StringUtils

    import nimble

    nimble.changeKeepAlive(keepAlive)

    conn = nimble.getConnection()

    #-----------------------------------------------------------------------------------------------
    # PING
    #       An empty call that tests that the Nimble connection is able to complete a request and
    #       response loop and prints the response object when complete.
    for i in range(iterations):
        result = conn.ping()
        if not runSilent:
            print(u'PING:', result.echo(True, True))

    #-----------------------------------------------------------------------------------------------
    # ECHO
    #       A basic call that sends an echo message, which the remote Nimble server returns in the
    #       response. Confirms that data can be set, read, and returned through the Nimble
    #       connection.
    smallMessage = 'This is a test'
    for i in range(iterations):
        result = conn.echo(smallMessage)
        if not runSilent:
            print(u'ECHO:', result.echo(True, True))

    #-----------------------------------------------------------------------------------------------
    # LONG ECHO
    #       A repeat of the echo test, but with a very long echo message that tests the ability for
    #       the Nimble socket protocols to chunk and stream large messages without losing data. The
    #       test is also repeated numerous times to confirm that the nimble socket connection
    #       survives through high-intensity multi-stage communication.
    largeMessage = StringUtils.getRandomString(64000)
    for i in range(iterations):
        result = conn.echo(largeMessage)
        if not runSilent:
            print(u'LARGE ECHO[#%s]:' % i, result.echo(True, True))

    print(u'\nTests Complete')
Пример #18
0
    def getTrackNode(self, track):
        """ This gets the (transient) Maya node name corresponding to a given
            track, or returns None if that track has not yet been loaded into
            Maya as a node. """

        # if asking for nothing, then get nothing in return
        if track is None:
            return None

        conn   = nimble.getConnection()
        result = conn.runPythonModule(
            GetTrackNodeProps,
            uid=track.uid,
            nodeName=track.nodeName,
            runInMaya=True)

        if result.payload.get('error'):
            print('Error in getTrackNode:', result.payload.get('message'))
            return False

        return result.payload.get('nodeName')
Пример #19
0
    def updateFromNode(self):
        """ Retrieves Maya values from the nodeName representation of the track
            and updates this model instance with those values. """

        conn   = nimble.getConnection()
        result = conn.runPythonModule(
            GetTrackNodeProps,
            uid=self.uid,
            nodeName=self.nodeName,
            runInMaya=True)
        if result.payload.get('error'):
            print('Error in updateFromNode:', result.payload.get('message'))
            return False

        self.nodeName = result.payload.get('nodeName')

        if self.nodeName:
            self.fromDict(result.payload.get('props'))
            return True

        return False
Пример #20
0
    def createTrackNode(self):
        """ Create a visual representation of a track, to signify the position,
            dimensions (length and width), and rotation of either a manus or pes
            track.  The representation has basic dimensions of one meter so that
            the scale in x and z equates to the width and length of the manus or
            pes in fractional meters (e.g., 0.5 = 50 cm).  The node is
            prohibited from changing in y (elevation) or to rotate about either
            x or z. """

        conn = nimble.getConnection()
        out  = conn.runPythonModule(
            CreateTrackNode,
            uid=self.uid,
            props=self.toMayaNodeDict(),
            runInMaya=True)
        if not out.success:
            print('Error in CreateNode:', out.error)
            return None

        self.nodeName = out.payload.get('nodeName')

        return self.nodeName
Пример #21
0
    def _handleExecuteCommand(self, payload):

        if 'commandID' in payload:
            command = AlloyData.getCommandData(payload['commandID'])
        elif 'variantID' in payload:
            command = AlloyData.getVariantData(payload['variantID'])
        else:
            return False

        if not command:
            return False

        if command['language'] == 'python':
            if command['location'] == 'remote':
                return remoteExec(command['script'])
            else:
                try:
                    conn = nimble.getConnection()
                    conn.runPythonScript(command['script'])
                except Exception, err:
                    print err
                    return False
Пример #22
0
            return False

        if command['language'] == 'python':
            if command['location'] == 'remote':
                return remoteExec(command['script'])
            else:
                try:
                    conn = nimble.getConnection()
                    conn.runPythonScript(command['script'])
                except Exception, err:
                    print err
                    return False
        else:
            print 'Executing mel script'
            try:
                conn = nimble.getConnection()
                conn.runMelScript(command['script'])
            except Exception, err:
                print err
                return False

        return True

#___________________________________________________________________________________________________ _handleGetImageCategories
    def _handleGetImageCategories(self, payload):
        out      = []
        rootPath = AlloyEnvironment.getRootIconPath()
        for p in os.listdir(rootPath):
            path = os.path.join(rootPath, p)
            if not os.path.isdir(path):
                continue
Пример #23
0
name = result[0]

offset = kwargs.get('offset', 10)

cmds.move(offset, offset, offset, name)
cmds.rotate(50, 20, 10, name)
cmds.scale(2, 2, 2, name)

response = nimble.createRemoteResponse(globals())
response.put('name', name)
response.put('offset', offset)
"""

#---------------------------------------------------------------------------------------------------
print('RUNNING SCRIPT:')
conn = nimble.getConnection()
result = conn.runPythonScript(script, offset=20)

print('\tRESULT:', result, type(result))
print('\tPAYLOAD:', result.payload)

#---------------------------------------------------------------------------------------------------
print('RUNNING FILE:')
result = conn.runPythonScriptFile(FileUtils.createPath(os.path.abspath(
    os.path.dirname(__file__)),
                                                       'pythonTestScript.py',
                                                       isFile=True),
                                  offset=5)

print('\tRESULT:', result, type(result))
print('\tPAYLOAD:', result.payload)
Пример #24
0
 def _runImpl(self):
     """Doc..."""
     self._output = nimble.getConnection().runPythonModule(*self._args, **self._kwargs)