Community
Maya Forum
Welcome to Autodesk’s Maya Forums. Share your knowledge, ask questions, and explore popular Maya topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Environment Variables Setup Frustrations

40 REPLIES 40
SOLVED
Reply
Message 1 of 41
FalconCrest
6140 Views, 40 Replies

Environment Variables Setup Frustrations

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 ?

 

 

40 REPLIES 40
Message 2 of 41
TechToast
in reply to: FalconCrest

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

Message 3 of 41
FalconCrest
in reply to: TechToast

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 !

Message 4 of 41
TechToast
in reply to: FalconCrest

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

Message 5 of 41
FalconCrest
in reply to: TechToast

Sorry, that should have read MAYA_SCRIPT_PATH !

Message 6 of 41
santd
in reply to: FalconCrest

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,




David Santos

Message 7 of 41
FalconCrest
in reply to: santd

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.

Message 8 of 41
santd
in reply to: FalconCrest

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,




David Santos

Message 9 of 41
FalconCrest
in reply to: santd


C:/Custom Settings/Maya_Resources/scripts;
I ran getenv "MAYA_SCRIPT_PATH";
C:/Custom Settings/Maya_Resources/scripts;
the above path is where all my scripts are located. There is also;
C:/Custom Program Settings/Maya_Resources/Preferences/scripts;
The difference between the second file scripts path is the script I want to run has a lock attached to it, if that means anything ?

The script I want to use, requires that I run a mel script from the command line, when I run that script I get the error; Cannot find procedure <name of mel script&gt; which means as you and I both know, that the script file can't be found, but the environment variable looks clean, as in, it's setup correctly as far as I'm aware.

Either file path doesn't work !

Message 10 of 41
santd
in reply to: FalconCrest

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,




David Santos

Message 11 of 41
FalconCrest
in reply to: santd

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 ? 🙂

Message 12 of 41
TechToast
in reply to: FalconCrest

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

Message 13 of 41
FalconCrest
in reply to: TechToast

Sorry, I don't understand. Are you saying if there are any functions in the script without the same name as the script, the script won't run ?
Message 14 of 41
TechToast
in reply to: FalconCrest

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

Message 15 of 41
FalconCrest
in reply to: TechToast

Your explanation is good, and I enjoyed reading it. I understand you can give functions the same name as the script; what I don't understand but you did explain the problem I am having with a script is if the script is firing this error:
//Error: line 1: Cannot find procedure "<name of script.mel>
How do I source the script, by simply;
source &lt;script.mel>; ?
Message 16 of 41
santd
in reply to: FalconCrest

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,




David Santos

Message 17 of 41
TechToast
in reply to: FalconCrest

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

Message 18 of 41
FalconCrest
in reply to: TechToast

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 ?

Message 19 of 41
TechToast
in reply to: FalconCrest

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

Message 20 of 41
FalconCrest
in reply to: TechToast

I'm in direct communication with the Author of this tool whom has told me to try placing the script files in Maya default path; maybe someone here can find a solution or there is an issue with the script ?
[Script]

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report