#1 08-04-2017 8:40 am

kpwale
Registered: 03-05-2015
Posts: 17

Run script whenever maya file is opened or loaded.<Solved>

Hi guys,
i want to run my script whenever maya file opens or loads.
I did source my script in usersetup.It works whenever maya opens but did not run script when maya file load or create new scene.
Can any one help me or give me any advice?

Offline

 

#2 08-04-2017 1:39 pm

RyanHagen
Upright Citizen
Registered: 06-16-2007
Posts: 1110
Karmojo: 48
Moderator

Re: Run script whenever maya file is opened or loaded.<Solved>

Is it a mel script or python script?


Ryan
Animator
"Frustration is the handmaiden of creativity" ~ Chuck Jones

Offline

 

#3 08-04-2017 3:50 pm

kpwale
Registered: 03-05-2015
Posts: 17

Re: Run script whenever maya file is opened or loaded.<Solved>

It is mel

Offline

 

#4 08-04-2017 4:18 pm

RyanHagen
Upright Citizen
Registered: 06-16-2007
Posts: 1110
Karmojo: 48
Moderator

Re: Run script whenever maya file is opened or loaded.<Solved>

If the script is called "yourscript" and has a function named "yourscript" than simply running.
yourscript(); would be enough. 

If you want a script to run on maya startup, just put the same command in the userSetup.mel as you would normally use to run the script.

Getting a script to start up on a new scene command would require script nodes.  You'll have to do some research here
https://knowledge.autodesk.com/support/ … d-htm.html

as i'm not entirely familiar with setting those up.  Hope that helps a bit more.


Ryan
Animator
"Frustration is the handmaiden of creativity" ~ Chuck Jones

Offline

 

#5 08-04-2017 4:35 pm

kpwale
Registered: 03-05-2015
Posts: 17

Re: Run script whenever maya file is opened or loaded.<Solved>

Yep, via usersetup.mel script runs when maya opens.But i want to open it when maya load new scene.

Offline

 

#6 08-04-2017 4:39 pm

RyanHagen
Upright Citizen
Registered: 06-16-2007
Posts: 1110
Karmojo: 48
Moderator

Re: Run script whenever maya file is opened or loaded.<Solved>

Check the link I included, you'll need to use script nodes for that.  It's doable, but i'm not entirely familiar with setting them    up.


Ryan
Animator
"Frustration is the handmaiden of creativity" ~ Chuck Jones

Offline

 

#7 08-09-2017 1:52 pm

kpwale
Registered: 03-05-2015
Posts: 17

Re: Run script whenever maya file is opened or loaded.<Solved>

If somebody need solution, just copy and paste this in userSetup :

global proc loadScripts(){
source "folder path";
}
loadScripts();

it works on maya 2016.Whenever maya opens or i open new scene my script runs big_smile big_smile big_smile


global proc loadScripts(){
MyScript;
}
loadScripts();


This also works when open maya but when you open new scene it does not work. sad sad sad

Offline

 

#8 08-09-2017 5:24 pm

zethicus
Celebrity
From: Mexico
Registered: 04-25-2011
Posts: 116
Karmojo: 66

Re: Run script whenever maya file is opened or loaded.<Solved>

have you guys tried changing your maya.env ? it works for my python and mel stuff


-Zeth

Offline

 

#9 08-10-2017 10:40 am

kpwale
Registered: 03-05-2015
Posts: 17

Re: Run script whenever maya file is opened or loaded.<Solved>

zethicus wrote:

have you guys tried changing your maya.env ? it works for my python and mel stuff

There is no code in maya.env so i did not change anything

Offline

 

#10 08-11-2017 12:19 am

zethicus
Celebrity
From: Mexico
Registered: 04-25-2011
Posts: 116
Karmojo: 66

Re: Run script whenever maya file is opened or loaded.<Solved>

You have to write it, it works as normal environment variables:

https://knowledge.autodesk.com/support/ … 4-htm.html

You point it to your scripts folder


-Zeth

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson