Can you demonstrate how you did this with references?

On Wed, Apr 6, 2011 at 11:12 AM, AndyLP <[email protected]> wrote:

> Hi Everyone,
> I'm new to working with the API so please bear with me!
>
> I'm trying to catch 'Error: Unable to load the image file, '/path/to/
> Image.jpg' and remedy it before the scene loads.
> I have successfully done this for broken reference paths, now I'm
> trying to do it for broken image paths.
>
> At the moment I'm using a callBack
>
> def fixImagePath( retCode ):
> #def fixImagePath(fileObject):
> #def fixImagePath(clientData):
>        print 'oepnSpecial: ', retCode
>        imagePlanes = OpenMaya.MItDependencyNodes( OpenMaya.MFn.kImagePlane
> )
>        while not imagePlanes.isDone():
>                print 'openSpecial: looped'
>                nodeFn = OpenMaya.MFnDependencyNode( imagePlanes.thisNode()
> )
>                plug = nodeFn.findPlug('imageName')
>                imageName = plug.asString()
>                imageName = imageName.replace( 'badPath', 'goodPath' )
>                plug.setString( imageName )
>                print 'openSpecial: ', imageName
>                imagePlanes.next()
>
> id =
> OpenMaya.MSceneMessage.addCallback(OpenMaya.MSceneMessage.kAfterOpen,
> fixImagePath)
>
> shot = mc.fileDialog(m=0)
>        if len(shot) > 0:
>                OpenMaya.MFileIO.open(shot, None, True)
>
> OpenMaya.MMessage.removeCallback(id)
>
>
> This kind of works.. though maya still prints the errors.. so there
> was no advantage to using the API, i may as well have written the code
> with the maya.cmds
> I would have thought the kBeforeOpenCheck would do it, but
> unfortunately the imagePath gets reset to the bad path when the scene
> loads up.
>
> Thoughts?
>
> AndyLP
>
>
> --
> http://groups.google.com/group/python_inside_maya
>

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

Reply via email to