Assuming your script that you want to run is in your PYTHONPATH, then you
just import it and call whatever you want on that imported module (I.e a
main() or some other function to run your action)
Using execfile is going to make an assumption about an absolute file
location (which may or may not be ideal). Using the normal python import
allows you to rely on the configured environment.

On Mon, 5 Oct 2015 7:28 PM Arvid Schneider <[email protected]> wrote:

> The userSetup.py is run each when maya is being started. You can have
> several userSetup.py files in your PYTHONPATH, but just one userSetup.mel.
>
> If you want to make the userSetup file clean you can call other .py files
> from within the userSetup using execfile().
> But you can also run your code directly in it.
>
> I hope that gets you started,
>
> Arvid Schneider
> Look Develpopment | Lighting TD | Show TD
> www.arvidschneider.com
>
>
> On Oct 5, 2015, at 05:51, Christopher. <[email protected]> wrote:
>
> The execfile() is located in my userSetup.py script, I was informed to put
> it there, another reason why I must learn Python soon, getting tired of the
> sloppy coding by some programmers, and when you don't know what is going
> on, you're led around by the nose.
>
> I want to add a script to automatically run when Maya starts ?
>
> On Sunday, October 4, 2015 at 7:34:36 PM UTC-4, Justin Israel wrote:
>>
>>
>>
>> On Mon, Oct 5, 2015 at 12:28 PM Christopher. <[email protected]>
>> wrote:
>>
>>> How do you add a script to the userSetup.py file.  Do you do it place
>>> after the - execfile('') ?
>>>
>>> Then define it as such
>>>
>>> def menuImport();
>>>      import <scriptName>
>>>
>>>
>>>
>>>
>>>
>> Which execfile() call are you referring to? userSetup.py is something
>> that gets automatically run by Maya at startup. It is just a normal python
>> script.
>>
>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Python Programming for Autodesk Maya" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/python_inside_maya/d229cd66-2267-46f1-b4e0-0c3a632f268f%40googlegroups.com
>>> <https://groups.google.com/d/msgid/python_inside_maya/d229cd66-2267-46f1-b4e0-0c3a632f268f%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/a6c927bf-6638-4f6e-8a25-bae7b89773e8%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/a6c927bf-6638-4f6e-8a25-bae7b89773e8%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/6FFB8CBD-E849-44BC-9B3A-EE9A45391D59%40gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/6FFB8CBD-E849-44BC-9B3A-EE9A45391D59%40gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA19FH%2B92UbcF8pzEWa595n1J28ycpTD56R%2BXsME8hFOEg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to