I can't run any third party script without the error "cannot find procedure". My Maya Environment variable points to a path where my scripts, icons even presets should be placed. When I place any scripts in the scripts path, then try to run those scripts I get the error ?
Solved! Go to Solution.
Solved by FalconCrest. Go to Solution.
Hi Falcon
Can you elaborate a little bit on what you are doing here? What is the 3rd party software you are trying to run? Are you running a MEL script or a Python script, or do you need to load any plug-ins prior to using the 3rd party software?
Often issues like this can be that you need to place scripts in the scripts folder and then rehash the script path. A simple way of ensuring this to just restart Maya once you have copied the scripts into the scripts folder.
If you can provide any more info I may be able to help a little more
Thanks
Mike
I have a folder on my drive, lets call that folder <Maya_Stuff> within that folder is another folder called <scripts> all MEL scripts that I want to use are placed within the <Maya_Stuff>\<scripts> folder if there are any icons that belong to the script they are in a subfolder of <Maya_Stuff> called <icons>. In my Maya.env file I have the following environment variables setup;
MAYA_SHELF_PATH = :\Maya_Stuff\Scripts \\ For any and all Script files
XBMLANGPATH = :\Maya_Stuff\Icons \\ For any and all icon files that may belong to the scripts
Most, if not all scripts require you to run a command to execute the script, whether you do that manually in Maya command line window or if you create a shelf icon, in this example suppose I run a command for a script manually in Maya command line window; and that command is called "acme.mel". I run "acme.mel" but I'm being informed that the procedure cannot be found yet the mel script is located in the :\Maya_Stuff\Scripts folder ?
This is the issue I am having, you can setup environment variables for Maya if you want to place things outside of Maya default locations, especially when upgrading Maya or upgrading scripts everything is kept organized, easier to maintain, that is not the case with my setup. I hope you or someone else can help so that any plugins or scripts that I install now, or in the future do not surface this problem, thank you !
Hi Falcon
It just looks like you are using the wrong environment variable. Instead of using MAYA_SHELF_PATH you need to use MAYA_SCRIPT_PATH.
Cheers
Mike
Hello,
Thank you for posting to The Area Forums.
A couple of things to take into consideration>
First, if you choose to define both a custom script path and a custom shelf path (that is, you set both MAYA_SHELF_PATH and MAYA_SCRIPT_PATH), the MAYA_SHELF_PATH must be listed first (before MAYA_SCRIPT_PATH) in Maya.env.
I didn't see that you had the shelf environment variable in your Maya.env file but I figured I would point that out.
Second, where are you keeping your Maya.env file? It should exist in the following directory:
Windows:
drive:\Documents and Settings\username\My Documents\maya
Mac:
/Users/username/Library/Preferences/Autodesk/maya
Linux:
~/maya
You can check to see if Maya is reading the Maya.env file by using the getenv command in Maya to check for the MAYA_SCRIPT_PATH variable as follows:
getenv "MAYA_SCRIPT_PATH";
I hope that is helpful.
Cheers,
Sorry I didn't mention, I set MAYA_APP_DIR in my Windows environment settings which contains a custom location for my maya.env file which is stated in the documentation.
Hello,
Did you try doing a getenv to see if Maya is picking up the proper value of your environment variable?
Another thing to try is reversing the slashes in your path sometimes Maya prefers them one way over the other.
Cheers,
Hello,
I think at this point we should test if it is your script or the path that isn't working. I have created testScript that when called will print "This script is working" place the attached mel script in your custom path and then launch Maya and in the Script Editor type testScript and run it to see if it prints "This script is working".
Since your script has a lock attached to it, it's possible that there are some permissions or security setttings applied to it which are not allowing access.
Cheers,
I put the script in the custom path that I created for which all my scripts are to be placed outside of the default maya path. As it goes, there is a environment variable set on my system, that environment variable is set to read the maya.env file that is placed in once again, a custom path on my computer, from there the environment variable tells maya where to look for icons, scripts and so forth, which are all custom paths on my system. I placed the script you suplied, thank you once again, in my custom script path, I ran the mel script in maya command line and I got the message; the script is working.
From the looks of it, I have setup everything correctly, therefore there must be something wrong with the scripts that I want to call themself, unless I'm missing something which at stage I'm positive I'm not ? 🙂
Hi again Falcon
As I don't know the ins-and-outs of what your scripts do I can't be sure about this but one thing you may have missed is that in order for you to be able to directly call a function within a script in the way you have described, the function must have the same name as the script. Otherwise Maya will not know that the function exists.
Otherwise you need to "source" the script using the source command.
Take the two examples below:
<File://MyTest1.mel>
global proc MyTest1()
{
print "Hello";
}
</File>
<File://MyTest2.mel>
global proc MyFunction()
{
print "Hello";
}
</File>
If both of these files were placed somewhere in your script path, only the first one could be directly called without a source statement. The second one would need to be sourced before the function was usable. i.e.
MyTest1();
// Hello
MyFunction();
// Error: line 1: Cannot find procedure "MyFunction". //
So instead you need to do:
source MyTest2.mel;
MyFunction();
// Hello
Hope this helps
Mike
OK, I'll try to explain.
Maya only compiles scripts it needs, at the moment that it needs them. This is for performance reasons.
The way scripts are compliled by Maya is by using the source command. Docs here.
Calling source actually compiles and executes the contents of the script. When this happens, all functions that exist in the script are created in the Maya runtime environment, making them "available" to call. So you can call any global function from that script once its been sourced.
There is also a clever shortcut built into Maya which allows you to name a function in a script with the same name as the script. If you do this Maya detects it at startup (different to sourcing). All you have to do is call the name of the script/function and Maya will actually source the entire script at that point.
So in the example below:
<File://MyFunctions.mel>
global proc Func1() {
print "Function 1";
}
global proc Func2() {
print "Function 2";
}
global proc MyFunctions() {
print "Main Function Has Been Run!";
}
</File>
Assuming this file were in your MAYA_SCRIPT_PATH, you would get the following results:
Func1();
// Error: line 1: Cannot find procedure "Func1". //
This is because the script wasn't sourced. So you need to either source the script:
source MyFunctions;
or just call the main function:
MyFunctions();
// Result: Main Function Has Been Run!
Now all of the functions are available from the script:
Func1();
// Result: Function 1
Func2();
// Result: Function 2
I hope this helps to clarify things
Mike
Hello,
I think the easiest solution if your main global proc name doesn't match the name of your script is to simply rename the script file so that it matches the global proc name then you should just be able to call it from Maya by typing the name and excecuting it in MEL.
If you would like you can attach the script for us to test or take a look at.
Cheers,
Hi Falcon
Yeah you can just source it by typing:
source "scriptName.mel" (with or without the ".mel" bit works fine)
If you run it and are getting this error:
// Error: Line 1.11: Cannot find file "scriptName" for source statement. //
it means the script is not in the MAYA_SCRIPT_PATH and the issue could be with your environment setup.
If you get no error it means the script was sourced successfully and all functions should be available.
If, after you have sourced it you are still getting an error when trying to call the procedure you want to use, then the issue is with the script itself and not your environment.
As David said in the previous post, you would need to attach your script for us to be able to offer any further help on the issue.
Mike
I ran the script using multiple variations, including with and without quotes. In all varations, I got no error, but the script did not run ?
I think its best that you post the script here so we can try to help you. Otherwise we're going to keep going round in circles. Also the output of your script window would be helpful too.
Mike