AREA forums upgrade
Read more about the planned upgrade of our forums
  • 1/3
You are here: Forum Home / Autodesk® Maya® / MEL / How do we execute a script every time any scene file is opened?
IMPORTANT ANNOUNCEMENT ABOUT AREA FORUMS
  RSS 2.0 ATOM  

How do we execute a script every time any scene file is opened?
Rate this thread
 
69386
 
Permlink of this thread  
avatar
  • Location: Punjab
  • Total Posts: 29
  • Joined: 20 September 2008 05:48 AM

I started coding in 2008 and wrote some scripts but later by 2009 I got job as vfx artist so got out of touch since I never dig into MEL, now I had to do some update to have it working with the Maya latest version or at least with 2011 ,
can anyone tell me how do I execute a script every time any scene file is opened ?

any help would be greatly appreciated…



Replies: 0
avatar
  • ldunham1
  • Posted: 26 July 2012 10:37 AM

afaik best bet for this could be a scriptJob…
userSetup’s would only execute on application startup.

http://download.autodesk.com/us/maya/2011help/CommandsPython/scriptJob.html

using an event-driven trigger (sceneOpened), should be fine as long as you keep on top of it logging the scriptJob id.



try pressing 'b'…
ldunham.blogspot.com

Replies: 1
/userdata/avatar/46r8x62qj.jpg

yes I had a look at it earlier,

so i came up with this in the usersetup.mel

scriptJob -event SceneOpened "myTestProc";
 
 global 
proc myTestProc()
 
{
 
if ( `objExists "autoSetProj"` )
 
{
 
// Do nothing
 
}
 
else
 
{
 string $nodeName 
= `scriptNode -st 1 -bs "source myProj.mel"  -n "autoSetProj"`; // inserts a script node caller to every scene file
 
source "myProj.mel";
 
}

  
 }

is their any other better way of doing it

Author: niceguysan

Replied: 26 July 2012 06:48 PM  
avatar

depending on your variables, the script jobs ID is rather unpredictable and can be different each time it’s created

one approach I used was scriptJob -lj, then tokenized the results to find my custom scriptjob, this way if it did exist, I knew for sure, I find the ID’s become a little less usefull when you start to build auto-loading tools

but at the same time I was searching for multiple different scriptjobs



Replies: 0