Thread: [cgkit-commits] SF.net SVN: cgkit: [62] maya/trunk/maya_wrapper/maya
Brought to you by:
mbaas
From: <mb...@us...> - 2006-09-27 11:28:50
|
Revision: 62 http://svn.sourceforge.net/cgkit/?rev=62&view=rev Author: mbaas Date: 2006-09-27 04:28:41 -0700 (Wed, 27 Sep 2006) Log Message: ----------- Moved pluginObject() out of __init__ into its own module so that it is possibel to import modules without triggering the import of _api. Modified Paths: -------------- maya/trunk/maya_wrapper/maya/__init__.py maya/trunk/maya_wrapper/maya/pluginmanager.py Added Paths: ----------- maya/trunk/maya_wrapper/maya/pluginobject.py Modified: maya/trunk/maya_wrapper/maya/__init__.py =================================================================== --- maya/trunk/maya_wrapper/maya/__init__.py 2006-09-26 16:44:04 UTC (rev 61) +++ maya/trunk/maya_wrapper/maya/__init__.py 2006-09-27 11:28:41 UTC (rev 62) @@ -20,22 +20,12 @@ # # ***** END LICENSE BLOCK ***** -import sys -import _api -#from node import Node +"""Maya/Python package. -def pluginObject(): - """Return the plugin object. +This package contains functionality to access Maya via Python. +It provides dynamic wrappers around all MEL functions as well as +wrappers around the C++ SDK classes. +""" - Returns the MObject that is passed to the initializePlugin() and - uninitializePlugin() functions. - """ - if not hasattr(sys, "__maya_pluginobj"): - raise RuntimeError, "Could not retrieve the plugin object" +#from node import Node - obj = sys.__maya_pluginobj - - if type(obj)==int: - return _api.toMObject(obj) - else: - raise RuntimeError, "Invalid plugin object type" Modified: maya/trunk/maya_wrapper/maya/pluginmanager.py =================================================================== --- maya/trunk/maya_wrapper/maya/pluginmanager.py 2006-09-26 16:44:04 UTC (rev 61) +++ maya/trunk/maya_wrapper/maya/pluginmanager.py 2006-09-27 11:28:41 UTC (rev 62) @@ -24,7 +24,7 @@ """ import sys, os, os.path, types -import maya +import pluginobject # Key: plugin name / Value: PluginInfo-Object _plugin_registry = {} @@ -96,7 +96,7 @@ # Call the uninit function and remove the plugin pinfo = _plugin_registry[pluginname] if pinfo.initstatus: - pinfo._uninitfunc(maya.pluginObject()) + pinfo._uninitfunc(pluginobject.pluginObject()) del _plugin_registry[pluginname] else: print 'Warning: Python plugin "%s" not registered'%pluginname @@ -144,7 +144,7 @@ raise RuntimeError, 'Plugin "%s": init/uninit functions not found'%pluginname # Call the init function... - stat = init(maya.pluginObject()) + stat = init(pluginobject.pluginObject()) # Create and initialize a PluginInfo object pinfo = PluginInfo(filename=filename, pluginname=pluginname, initfunc=init, uninitfunc=uninit, initstatus=stat) Added: maya/trunk/maya_wrapper/maya/pluginobject.py =================================================================== --- maya/trunk/maya_wrapper/maya/pluginobject.py (rev 0) +++ maya/trunk/maya_wrapper/maya/pluginobject.py 2006-09-27 11:28:41 UTC (rev 62) @@ -0,0 +1,44 @@ +# ***** BEGIN LICENSE BLOCK ***** +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is the Python Computer Graphics Kit. +# +# The Initial Developer of the Original Code is Matthias Baas. +# Portions created by the Initial Developer are Copyright (C) 2005 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# +# ***** END LICENSE BLOCK ***** + +"""Retrieve the Maya plugin object. +""" + +import sys +import _api + + +def pluginObject(): + """Return the plugin object. + + Returns the MObject that is passed to the initializePlugin() and + uninitializePlugin() functions. + """ + if not hasattr(sys, "__maya_pluginobj"): + raise RuntimeError, "Could not retrieve the plugin object" + + obj = sys.__maya_pluginobj + + if type(obj)==int: + return _api.toMObject(obj) + else: + raise RuntimeError, "Invalid plugin object type" Property changes on: maya/trunk/maya_wrapper/maya/pluginobject.py ___________________________________________________________________ Name: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mb...@us...> - 2006-10-03 10:40:08
|
Revision: 88 http://svn.sourceforge.net/cgkit/?rev=88&view=rev Author: mbaas Date: 2006-10-03 03:39:55 -0700 (Tue, 03 Oct 2006) Log Message: ----------- Moved some functions from _mel to melutils (so that they can also be used in the remote sub-package and elsewhere). Modified Paths: -------------- maya/trunk/maya_wrapper/maya/_mel/__init__.py maya/trunk/maya_wrapper/maya/gui/guiobjectbase.py Added Paths: ----------- maya/trunk/maya_wrapper/maya/melutils.py Modified: maya/trunk/maya_wrapper/maya/_mel/__init__.py =================================================================== --- maya/trunk/maya_wrapper/maya/_mel/__init__.py 2006-10-03 10:12:08 UTC (rev 87) +++ maya/trunk/maya_wrapper/maya/_mel/__init__.py 2006-10-03 10:39:55 UTC (rev 88) @@ -57,6 +57,7 @@ ''' import types +import maya.melutils as _melutils from maya.api import MGlobal as _MGlobal from maya.api import MString as _MString @@ -70,141 +71,7 @@ # This flag is used when MEL commands are executed _undoEnabled = False -# _parseHelp -def _parseHelp(help): - """Parse a help string and return the keyword arguments and the doc string. - help is the string obtained by the 'help' MEL command. - The function returns a tuple (flags, multiuse_dict, docstring) where - flags is a list of 4-tuples (shortname, longname, type, multiuse) - multiuse_dict is a dictionary containing those option names that are - multi-use options (short and long names). The key is the option - name and the value is irrelevant (non-multi-use options are not - added to the dictionary). docstring contains the reformatted help - text which can be used as doc string in the source code that will - be generated. - """ - lines = help.split("\n") - - # Strip leading newlines - while lines[0]=="": - lines = lines[1:] - # Strip trailing newlines - while lines[-1]=="": - lines = lines[:-1] - - flags = [] - multiuse_dict = {} - doc = [] - for nr,line in enumerate(lines): - a = line.split() - # Does the line contain flags? - if len(a)>1 and a[0][0]=='-' and a[1][0]=='-': - shortname = a[0][1:] - longname = a[1][1:] - if a[-1]=="(multi-use)": - multiuse = True - multiuse_dict[shortname] = 1 - multiuse_dict[longname] = 1 - type = a[2:-1] - else: - multiuse = False - type = a[2:] - flags.append((shortname, longname, type, multiuse)) - - if nr>0: - line = " "+line - doc.append(line) - - return flags, multiuse_dict, "\n".join(doc) - -# _py2mel -def _py2mel(val): - """Convert a Python value into valid MEL code that recreates that value. - - Returns a string with the MEL expression. - """ -# print "py2mel(%s:%s)"%(val, type(val)) - - vtype = type(val) - # Scalar? - if vtype==int or vtype==float or vtype==long: - return str(val) - # Boolean? - elif vtype==bool: - if val: - return "1" - else: - return "0" - # String? - elif vtype==str or vtype==unicode or isinstance(val, _MString): - # Replace special characters... - val = val.replace("\n", "\\n") - val = val.replace("\t", "\\t") - val = val.replace('"', '\\"') - return '"%s"'%val - # None? - elif val==None: - return "" - # List? -> convert to a MEL array - elif vtype==list: - toks = map(lambda v: _py2mel(v), val) - return "{%s}"%(", ".join(toks)) - # Anything else? Then it's either a sequence or a Python object that - # represents a Maya object and whose __str__ method returns the - # Maya name... - else: - # Check if it really is a sequence... - try: - size = len(val) - except: - return str(val) -# raise ValueError, "Sequence expected, got %s instead."%(vtype) - toks = map(lambda v: _py2mel(v), val) - return " ".join(toks) - -##def _py2mel_old(seq): -## """Return a list of the individual items in a (possibly nested) sequence. - -## Returns a list with all items as strings. -## If an item was already a string it's enclosed in apostrophes. - -## Example: _py2mel( [(1,2,3), (4,5,6)] ) -> ["1","2","3","4","5","6"] -## _py2mel( ("str1","str2") ) -> ['"str1"','"str2"'] -## """ -## res = [] -## ScalarTypes = [types.IntType, types.LongType, types.FloatType] -## StringType = types.StringType -## for v in seq: -## vtype = type(v) -## # v=scalar? -## if vtype in ScalarTypes: -## res.append(str(v)) -## # v=string? -## elif vtype==StringType: -## v = v.replace('"', '\\"') -## res.append('"%s"'%v) -## # bool? -## elif vtype==bool: -## if v: -## res.append('1') -## else: -## res.append('0') -## # v=list? convert to MEL array -## elif vtype==list: -## toks = _py2mel(v) -## res.append("{%s}"% ", ".join(toks)) -## # no scalar, string or list. Then it's supposed to be a sequence which is converted -## # to a list of individual values... -## else: -## try: -## size = len(v) -## except: -## raise ValueError, "Sequence expected, got %s instead."%(vtype) -## res += _py2mel(v) -## return res - - # _call def _call(_funcname, _multiuse={}, *args, **flags): """Invoke a MEL command. @@ -215,48 +82,7 @@ """ # print "_call(%s, %s, %s, %s)"%(_funcname, _multiuse, args, flags) - # toks is a list of tokens that will be concatenated to form the - # final MEL command. Begin with the command name - toks = [_funcname] - - # Search for the query/edit flags first as these must be at the front - # of the flag list... - if "query" in flags: - toks += ["-query"] - del flags["query"] - if "q" in flags: - toks += ["-q"] - del flags["q"] - if "edit" in flags: - toks += ["-edit"] - del flags["edit"] - if "e" in flags: - toks += ["-e"] - del flags["e"] - - # Add the flags... - for flag in flags: - val = flags[flag] - # Is this a multi-use flag? - if flag in _multiuse: - if type(val) not in [list, tuple]: - val = [val] - # Add the option before each individual value... - for v in val: - toks.append("-"+flag) - toks.append(_py2mel(v)) - else: - # It's a normal flag, so the option only appears once... - toks.append("-"+flag) - if val!=None: - toks.append(_py2mel(val)) - - # ...and the arguments - for arg in args: - toks.append(_py2mel(arg)) - - # Combine all the tokens and execute the command - cmd = " ".join(toks) + cmd = _melutils.melCmdStr(_funcname, _multiuse, *args, **flags) if _debug: print "***MEL command:",cmd return _MGlobal.executeCommandPy(cmd, displayEnabled=_displayEnabled, undoEnabled=_undoEnabled) @@ -301,7 +127,7 @@ # Get the help text for the current command help = _MGlobal.executeCommandPy('help %s'%cmd) - flags, multiuse, doc = _parseHelp(help) + flags, multiuse, doc = _melutils.parseHelp(help) # Add a prefix if a function has the name of a Python keyword... if cmd in pykeywords: @@ -344,7 +170,7 @@ _MGlobal.executeCommandPy('progressWindow -edit -progress %d -status "Completed %d%s"'%(_i,int(100*_i/len(_cmdlst)),"%")) -_MGlobal.executeCommandPy('progressWindow -endProgress') +_MGlobal.executeCommandOnIdle('progressWindow -endProgress') #_MGlobal.displayInfo(_MString("Finished creating Python MEL wrappers")) #_MGlobal.executeCommandPy("waitCursor -state off") Modified: maya/trunk/maya_wrapper/maya/gui/guiobjectbase.py =================================================================== --- maya/trunk/maya_wrapper/maya/gui/guiobjectbase.py 2006-10-03 10:12:08 UTC (rev 87) +++ maya/trunk/maya_wrapper/maya/gui/guiobjectbase.py 2006-10-03 10:39:55 UTC (rev 88) @@ -26,7 +26,8 @@ import maya.api import maya.gui from maya import mel -from maya import _mel +#from maya import _mel +from maya import melutils import types, copy, inspect executeCommand = maya.api.MGlobal.executeCommandPy @@ -111,7 +112,7 @@ self.callbackattrs = {} # Create a flag index... - self.flags = _mel._parseHelp(mel.help(melcmdname))[0] + self.flags = maya.melutils.parseHelp(mel.help(melcmdname))[0] # Key:name Value:short,long,type,multiuse index_dict = {} for short,long,type,multiuse in self.flags: @@ -381,7 +382,7 @@ elif shortname in cdesc.callbackattrs: val = self._callbackAttrValue(shortname, val) - melval = _mel._py2mel(val) + melval = melutils.py2mel(val) cmd = "%s -e -%s %s %s"%(self._classname, name, melval, self._name) # print "***CMD:",cmd executeCommand(cmd) Added: maya/trunk/maya_wrapper/maya/melutils.py =================================================================== --- maya/trunk/maya_wrapper/maya/melutils.py (rev 0) +++ maya/trunk/maya_wrapper/maya/melutils.py 2006-10-03 10:39:55 UTC (rev 88) @@ -0,0 +1,238 @@ +# ***** BEGIN LICENSE BLOCK ***** +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is the Python Computer Graphics Kit. +# +# The Initial Developer of the Original Code is Matthias Baas. +# Portions created by the Initial Developer are Copyright (C) 2005 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# +# ***** END LICENSE BLOCK ***** + +# parseHelp +def parseHelp(help): + """Parse a help string and return the keyword arguments and the doc string. + + help is the string obtained by the 'help' MEL command. + The function returns a tuple (flags, multiuse_dict, docstring) where + flags is a list of 4-tuples (shortname, longname, type, multiuse) + multiuse_dict is a dictionary containing those option names that are + multi-use options (short and long names). The key is the option + name and the value is irrelevant (non-multi-use options are not + added to the dictionary). docstring contains the reformatted help + text which can be used as doc string in the source code that will + be generated. + """ + lines = help.split("\n") + + # Strip leading newlines + while lines[0]=="": + lines = lines[1:] + # Strip trailing newlines + while lines[-1]=="": + lines = lines[:-1] + + flags = [] + multiuse_dict = {} + doc = [] + for nr,line in enumerate(lines): + a = line.split() + # Does the line contain flags? + if len(a)>1 and a[0][0]=='-' and a[1][0]=='-': + shortname = a[0][1:] + longname = a[1][1:] + if a[-1]=="(multi-use)": + multiuse = True + multiuse_dict[shortname] = 1 + multiuse_dict[longname] = 1 + type = a[2:-1] + else: + multiuse = False + type = a[2:] + flags.append((shortname, longname, type, multiuse)) + + if nr>0: + line = " "+line + doc.append(line) + + return flags, multiuse_dict, "\n".join(doc) + +# py2mel +def py2mel(val): + """Convert a Python value into valid MEL code that recreates that value. + + Returns a string with the MEL expression. + + >>> py2mel(5) + '5' + >>> py2mel(5L) + '5' + >>> py2mel(5.5) + '5.5' + >>> py2mel(True) + '1' + >>> py2mel(False) + '0' + >>> py2mel("spam") + '"spam"' + >>> py2mel(u"spam") + u'"spam"' + >>> py2mel('"spam"') + '"\\\\"spam\\\\""' + >>> py2mel(None) + '' + >>> py2mel([1,2,3]) + '{1, 2, 3}' + >>> py2mel((1,2,3)) + '1 2 3' + """ +# print "py2mel(%s:%s)"%(val, type(val)) + + vtype = type(val) + # Scalar? + if vtype==int or vtype==float or vtype==long: + return str(val) + # Boolean? + elif vtype==bool: + if val: + return "1" + else: + return "0" + # String? + elif vtype==str or vtype==unicode: # or isinstance(val, _MString): + # Replace special characters... + val = val.replace("\n", "\\n") + val = val.replace("\t", "\\t") + val = val.replace('"', '\\"') + return '"%s"'%val + # None? + elif val==None: + return "" + # List? -> convert to a MEL array + elif vtype==list: + toks = map(lambda v: py2mel(v), val) + return "{%s}"%(", ".join(toks)) + # Anything else? Then it's either a sequence or a Python object that + # represents a Maya object and whose __str__ method returns the + # Maya name... + else: + # Check if it really is a sequence... + try: + size = len(val) + except: + return str(val) +# raise ValueError, "Sequence expected, got %s instead."%(vtype) + toks = map(lambda v: py2mel(v), val) + return " ".join(toks) + +##def _py2mel_old(seq): +## """Return a list of the individual items in a (possibly nested) sequence. + +## Returns a list with all items as strings. +## If an item was already a string it's enclosed in apostrophes. + +## Example: _py2mel( [(1,2,3), (4,5,6)] ) -> ["1","2","3","4","5","6"] +## _py2mel( ("str1","str2") ) -> ['"str1"','"str2"'] +## """ +## res = [] +## ScalarTypes = [types.IntType, types.LongType, types.FloatType] +## StringType = types.StringType +## for v in seq: +## vtype = type(v) +## # v=scalar? +## if vtype in ScalarTypes: +## res.append(str(v)) +## # v=string? +## elif vtype==StringType: +## v = v.replace('"', '\\"') +## res.append('"%s"'%v) +## # bool? +## elif vtype==bool: +## if v: +## res.append('1') +## else: +## res.append('0') +## # v=list? convert to MEL array +## elif vtype==list: +## toks = _py2mel(v) +## res.append("{%s}"% ", ".join(toks)) +## # no scalar, string or list. Then it's supposed to be a sequence which is converted +## # to a list of individual values... +## else: +## try: +## size = len(v) +## except: +## raise ValueError, "Sequence expected, got %s instead."%(vtype) +## res += _py2mel(v) +## return res + + +# melCmdStr +def melCmdStr(_funcname=None, _multiuse={}, *args, **flags): + """Return a MEL command string. + + _funcname is the name of the MEL command. _multiuse is a dictionary + that contains the names of the multi-use options. args contains + the arguments and flags the options. + """ + + # toks is a list of tokens that will be concatenated to form the + # final MEL command. Begin with the command name + if _funcname: + toks = [_funcname] + else: + toks = [] + + # Search for the query/edit flags first as these must be at the front + # of the flag list... + if "query" in flags: + toks += ["-query"] + del flags["query"] + if "q" in flags: + toks += ["-q"] + del flags["q"] + if "edit" in flags: + toks += ["-edit"] + del flags["edit"] + if "e" in flags: + toks += ["-e"] + del flags["e"] + + # Add the flags... + for flag in flags: + val = flags[flag] + # Is this a multi-use flag? + if flag in _multiuse: + if type(val) not in [list, tuple]: + val = [val] + # Add the option before each individual value... + for v in val: + toks.append("-"+flag) + toks.append(py2mel(v)) + else: + # It's a normal flag, so the option only appears once... + toks.append("-"+flag) + if val!=None: + toks.append(py2mel(val)) + + # ...and the arguments + for arg in args: + toks.append(py2mel(arg)) + + # Combine all the tokens and execute the command + cmd = " ".join(toks) +# if _debug: +# print "***MEL command:",cmd + return cmd + Property changes on: maya/trunk/maya_wrapper/maya/melutils.py ___________________________________________________________________ Name: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mb...@us...> - 2006-10-15 21:38:35
|
Revision: 126 http://svn.sourceforge.net/cgkit/?rev=126&view=rev Author: mbaas Date: 2006-10-15 14:38:24 -0700 (Sun, 15 Oct 2006) Log Message: ----------- Ignore *.pyc files Property Changed: ---------------- maya/trunk/maya_wrapper/maya/_mel/ maya/trunk/maya_wrapper/maya/mel/ Property changes on: maya/trunk/maya_wrapper/maya/_mel ___________________________________________________________________ Name: svn:ignore + *.pyc Property changes on: maya/trunk/maya_wrapper/maya/mel ___________________________________________________________________ Name: svn:ignore + *.pyc This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mb...@us...> - 2006-10-03 10:40:48
|
Revision: 89 http://svn.sourceforge.net/cgkit/?rev=89&view=rev Author: mbaas Date: 2006-10-03 03:40:34 -0700 (Tue, 03 Oct 2006) Log Message: ----------- Added the remote sub-package. Added Paths: ----------- maya/trunk/maya_wrapper/maya/remote/ maya/trunk/maya_wrapper/maya/remote/__init__.py maya/trunk/maya_wrapper/maya/remote/mel.py Added: maya/trunk/maya_wrapper/maya/remote/__init__.py =================================================================== --- maya/trunk/maya_wrapper/maya/remote/__init__.py (rev 0) +++ maya/trunk/maya_wrapper/maya/remote/__init__.py 2006-10-03 10:40:34 UTC (rev 89) @@ -0,0 +1,75 @@ +# ***** BEGIN LICENSE BLOCK ***** +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is the Python Computer Graphics Kit. +# +# The Initial Developer of the Original Code is Matthias Baas. +# Portions created by the Initial Developer are Copyright (C) 2005 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# +# ***** END LICENSE BLOCK ***** + +"""This sub-package contains functionality to control Maya remotely. +""" + +# The parameters for the mel module +_server_url = "http://localhost" +_server_port = 4870 + +# init +def init(server=None, port=None): + """Initialize the remote module. + + server is a string containing the server address to connect to. + The server string may contain an optional port number or you may + specify the port number via the port argument. + + This function must be called before remove.mel is imported, otherwise + it won't have an effect. + """ + global _server_url + global _server_port + + # Server? + if server!=None: + a = server.split("://") + # No addressing scheme? + if len(a)==1: + addr = server + else: + if a[0].lower()!="http": + raise ValueError, "Invalid addressing scheme: '%s'"%a[0] + addr = a[1] + + # Check if there's a port value specified + a = addr.split(":") + if len(a)>2: + raise ValueError, "Invalid server address: %s"%server + addr = a[0] + if len(a)==2 and a[1]!="": + try: + portnr = int(a[1]) + except ValueError: + raise ValueError, "Invalid port number: %s"%a[1] + _server_port = portnr + + _server_url = "http://"+addr + + # Port? + if port!=None: + try: + port = int(port) + except ValueError: + raise ValueError, "Invalid port number: %s"%port + _server_port = port Property changes on: maya/trunk/maya_wrapper/maya/remote/__init__.py ___________________________________________________________________ Name: svn:eol-style + native Added: maya/trunk/maya_wrapper/maya/remote/mel.py =================================================================== --- maya/trunk/maya_wrapper/maya/remote/mel.py (rev 0) +++ maya/trunk/maya_wrapper/maya/remote/mel.py 2006-10-03 10:40:34 UTC (rev 89) @@ -0,0 +1,81 @@ +# ***** BEGIN LICENSE BLOCK ***** +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is the Python Computer Graphics Kit. +# +# The Initial Developer of the Original Code is Matthias Baas. +# Portions created by the Initial Developer are Copyright (C) 2005 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# +# ***** END LICENSE BLOCK ***** + +'''This module generates MEL command proxy functions. + +The module initialization code obtains a list of MEL commands from +the server and generates a proxy function like the following for +each command: + +# curve +def curve(*args, **flags): + """Synopsis: curve [flags] [String...] + Flags: + -a -append + -d -degree Float + -k -knot Float (multi-use) + -n -name String + -os -objectSpace + -p -point Length Length Length (multi-use) + -per -periodic on|off + -pw -pointWeight Length Length Length Length (multi-use) + -r -replace + -ws -worldSpace + + """ + global _server + multiuse = {'pw': 1, 'pointWeight': 1, 'k': 1, 'point': 1, 'p': 1, 'knot': 1} + argstr = maya.melutils.melCmdStr("", multiuse, *args, **flags) + return _server.executeMEL("curve", argstr) + +''' + +import xmlrpclib +import maya.melutils +import maya.remote + +# Connect to the server... +_url = "%s:%s"%(maya.remote._server_url, maya.remote._server_port) +print "Connecting to %s..."%_url +_server = xmlrpclib.ServerProxy(_url, allow_none=True) + +# Create the MEL proxies... +_infos = _server.getCommandInfos() +for _name,_docstr in _infos: + + # Recreate the multiuse dictionary + _flags, _multiuse, _doc = maya.melutils.parseHelp(_docstr) + + # Create the source code for the proxy functions... + _src = '# %s\n'%_name + _src += 'def %s(*args, **flags):\n'%(_name) + _src += ' """%s\n """\n'%_docstr + _src += ' global _server\n' + if _multiuse=={}: + _multiusearg = "{}" + else: + _src += " multiuse = %s\n"%repr(_multiuse) + _multiusearg = "multiuse" + _src += ' argstr = maya.melutils.melCmdStr("", %s, *args, **flags)\n'%(_multiusearg) + _src += ' return _server.executeMEL("%s", argstr)\n'%_name + + exec _src Property changes on: maya/trunk/maya_wrapper/maya/remote/mel.py ___________________________________________________________________ Name: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mb...@us...> - 2006-10-03 14:21:54
|
Revision: 96 http://svn.sourceforge.net/cgkit/?rev=96&view=rev Author: mbaas Date: 2006-10-03 07:21:47 -0700 (Tue, 03 Oct 2006) Log Message: ----------- Ignore *.pyc files. Property Changed: ---------------- maya/trunk/maya_wrapper/maya/ maya/trunk/maya_wrapper/maya/api/ Property changes on: maya/trunk/maya_wrapper/maya ___________________________________________________________________ Name: svn:ignore + *.pyc Property changes on: maya/trunk/maya_wrapper/maya/api ___________________________________________________________________ Name: svn:ignore + *.pyc This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |