What error are you getting exactly?The try/except block is silencing the specifics of the error, so it's hard to track it down that way. Try it with the the try/except and send us the results?
On Thu, Dec 25, 2008 at 9:22 PM, debug <[email protected]> wrote: > > Hi- > > Sorry yeah it was only a partial paste the entire function is: > > def initializePlugin(mobject): > mplugin = OpenMayaMPx.MFnPlugin(mobject, softwareVendor, > softwareVersion, "Any") > try: > > mplugin.registerCommand(kPluginCmdName, cmdCreator, > syntaxCreator) > mplugin.addMenuItem(Cool, "MayaWindow", "Sphere", "") > except: > sys.stderr.write( "Failed to register command: %s\n" % > kPluginCmdName ) > raise > > and there is an uninitalizeFunction as well. > > Thanks > > Dommm > > On Dec 26, 5:17 am, Hradec <[email protected]> wrote: > > interesting problem... one question... in the code you put in the email, > you > > open a "try:" but theres no "except:" after... maybe the error you're > > getting is because of that? or did you just didn't paste it? > > > > just wondering... > > > > On Thu, Dec 25, 2008 at 9:16 PM, Hradec <[email protected]> wrote: > > > interesting problem... one question... in the code you put in the > email, > > > you open a "try:" but theres no "except:" after... maybe the error > you're > > > getting is because of that? or did you just didn't paste it? > > > > > just wondering... > > > > > -H > > > > > On Thu, Dec 25, 2008 at 12:11 PM, debug <[email protected]> wrote: > > > > >> Thanks! That worked perfectly after I integrated it into my code. > > > > >> I've one more problem thats unrelated. Know what's going on here? > > > > >> When trying to add a menu system via the initalizePlugin function I'm > > >> getting an error despite it all the arguments being passed correctly > > >> to the function: > > > > >> def initializePlugin(mobject): > > >> mplugin = OpenMayaMPx.MFnPlugin(mobject) > > >> try: > > > > >> mplugin.registerCommand(kPluginCmdName, cmdCreator, > > >> syntaxCreator) > > >> mplugin.addMenuItem("Cool", "MayaWindow", "Sphere", "") > > > > >> Thanks again. > > > > >> dommmm > > > > >> On Dec 25, 6:14 pm, Hradec <[email protected]> wrote: > > >> > Hi there... > > > > >> > sys.argv[0] returns the first argument of the command line executed > to > > >> > run the current application. When inside maya, it will return the > > >> > command line executed to run maya itself, therefore the result > you're > > >> > getting. > > > > >> > What you can do is to get what you want is: in the same folder where > > >> > you plugin is, create another file named something like > > >> > "pluginLocation.py" or something like that. > > > > >> > fill it with something simple, like just "impor os" > > > > >> > after you load your plugin in maya, go to the script editor and > type: > > > > >> > import pluginLocation > > >> > import os > > >> > currentDir = os.path.dirname(pluginLocation.__file__) > > >> > print currentDir > > > > >> > this will give you the folder where your plugin is. > > > > >> > when you load a plugin in maya, maya allways adds the plugin path to > > >> > the python search path, so if the plugin has some sub-modules in the > > >> > same folder (like our pluginLocation.py) it can just import then > > >> > normally. And all modules have the __file__ var that stores its > path. > > > > >> > Let me know if it works... > > > > >> > have fun... > > > > >> > -H > > > > >> > On Dec 24, 5:55 pm, debug <[email protected]> wrote: > > > > >> > > Hi- > > >> > > I'm currently trying to work out the current location of the > current > > >> > > running python plugin to get the path of a normal python I always > use: > > > > >> > > currentDir = sys.argv[0] > > >> > > print (currentDir) > > > > >> > > However when I use it from a running python plugin I get the > result: > > > > >> > > /Applications/Autodesk/maya2009/Maya.app/Contents/MacOS/Maya > > > > >> > > Which isn't the right path obviously. > > > > >> > > Any ideas whats going on? > > > > >> > > Many thanks in advance > > > > >> > > Dom > > > -- - Ofer www.mrbroken.com --~--~---------~--~----~------------~-------~--~----~ Yours, Maya-Python Club Team. -~----------~----~----~----~------~----~------~--~---
