[Maya-Python] Hijacking reference loading on Scene Load

956 views
Skip to first unread message

Jay Goodman

unread,
May 14, 2010, 4:59:36 PM5/14/10
to python_inside_maya
I was curious if anyone has tried to do this. Basically we are trying
to prevent maya from loading any references by default and instead
load them ourselves. This is because there are some references we
'auto cleanup' and some we don't. I am trying to do this by setting
an "addCheckFileCallback" on "kBeforeLoadReferenceCheck".
This gets called for every Reference that "wants" to be loaded, caches
the file path, and prevents Maya from doing the reference. This
method has a FileObj representing the reference about to be loaded as
an argument. Now for the majority of scene files, this will work, but
there will be problems if the same file is referenced multiple times.
I can't find any way to connect the FileObj to a ReferenceNode? The
only workaround I can think up is to just add a "{%d}" % i to the end
of the string, but even that method will find an issue of you are
opening a scene with multiple references of the same file, and they
aren't all loaded. Any thoughts on this? Thanks a lot!

--
http://groups.google.com/group/python_inside_maya

Matt Estela

unread,
May 14, 2010, 8:11:02 PM5/14/10
to python_in...@googlegroups.com
using the file->open->option box->selective preload wouldn't work for
you? sorry if i misunderstood the question and you definitely
want/need a python solution...


On Sat, May 15, 2010 at 6:59 AM, Jay Goodman <jaycg...@gmail.com> wrote:
> I was curious if anyone has tried to do this.  Basically we are trying
> to prevent maya from loading any references by default and instead
> load them ourselves.  This is because there are some references we

--
http://groups.google.com/group/python_inside_maya

Jay Goodman

unread,
May 14, 2010, 8:42:16 PM5/14/10
to python_inside_maya
I had never actually tried preload. ha. The UI itself won't help, but
your suggestion sure does! I tracked down the mel for this ui and
found that it used the command: selLoadSettings. Now this is the
command I needed!

If I run selLoadSettings in the BeforeLoadReference callback, I can
basically get a list of all the reference nodes that are 'about to be'
loaded, store them, and tell them not to load.
Thanks for your suggestion. You totally nudged me in the right
direction.
Jay

On May 14, 5:11 pm, Matt Estela <matt.est...@gmail.com> wrote:
> using the file->open->option box->selective preload wouldn't work for
> you? sorry if i misunderstood the question and you definitely
> want/need a python solution...
>
> On Sat, May 15, 2010 at 6:59 AM, Jay Goodman <jaycgood...@gmail.com> wrote:
> > I was curious if anyone has tried to do this.  Basically we are trying
> > to prevent maya from loading any references by default and instead
> > load them ourselves.  This is because there are some references we
>
> --http://groups.google.com/group/python_inside_maya

--
http://groups.google.com/group/python_inside_maya

Matt Estela

unread,
May 15, 2010, 8:45:18 AM5/15/10
to python_in...@googlegroups.com
cool. :)

On Sat, May 15, 2010 at 10:42 AM, Jay Goodman <jaycg...@gmail.com> wrote:
> I had never actually tried preload. ha.  The UI itself won't help, but
> your suggestion sure does!  I tracked down the mel for this ui and
> found that it used the command: selLoadSettings.  Now this is the
> command I needed!
>

--
http://groups.google.com/group/python_inside_maya
Reply all
Reply to author
Forward
0 new messages