Re: [Maya-Python] changing path to references witha callback

2017-11-30 Thread Michał Frątczak
Thanks !
This linked me to http://forums.cgsociety.org/showthread.php?t=968717
Which is precisely what I needed.

cheers
-michal


On Wednesday, November 29, 2017 at 7:40:38 PM UTC+1, Robert White wrote:
>
>
> MSceneMessage.addCheckFileCallback with kBeforeLoadReferenceCheck should 
> get you what you want. 
>
> You'll get a reference to the file object before the reference has been 
> loaded, and you should be able to tweak and update the file paths from 
> there. 
> I've used this in the past to fix issues where some machines were 
> replacing environment variables with the full path.
>
>>
>>
 

-- 
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 python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/2f49d523-4ff6-4c4c-ba58-8afe393b1a31%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] changing path to references witha callback

2017-11-29 Thread Robert White

MSceneMessage.addCheckFileCallback with kBeforeLoadReferenceCheck should 
get you what you want. 

You'll get a reference to the file object before the reference has been 
loaded, and you should be able to tweak and update the file paths from 
there. 
I've used this in the past to fix issues where some machines were replacing 
environment variables with the full path.


On Wednesday, November 29, 2017 at 11:23:25 AM UTC-6, Michał Frątczak wrote:
>
> Yeah, dirmap is better. If only I could remember how I did it last time :)
> Will use dirmap() from now on, thanks !
>
>
> W dniu 29.11.2017 o 18:12, Mahendra Gangaiwar pisze:
>
> I think better approach here would be make use of "dirmap" command, so you 
> could map Linux to Windows and vice versa.. 
>
> Something like this:
>
> dirmap("//server", "/server");
> dirmap("/server", "//server");
>
> Try running above command, and open file, all references and texture paths 
> should remapped automatically by Maya.
>
> On Wed 29 Nov, 2017, 9:34 PM Michał Frątczak,  > wrote:
>
>> Hi
>>
>> We move maya scenes between linux and windows machines.
>> When linux references a file it uses UNC paths like: 
>> /server/project/file.ext
>> whereas windows needs double slash in front: //server/project/file.ext
>>
>> I have a MSceneMessage.kBeforeSave callback that fixes paths on texture 
>> nodes (ensures leading //).
>> I remember having done similar thing with references too, but I lost the 
>> script and can't recall details... any hints how to change path to 
>> reference ?
>>
>> Here is my texture fixing code:
>>
>> def addFirstSlash(i_str):
>> if i_str[0] == '/' and i_str[1] != '/':
>> return '/' + i_str
>> return i_str
>>
>> def mf_MSceneMessage_BeforeSave_CB(*args, **kwargs):
>> for f in mc.ls(type='file'):
>> mc.setAttr(f + '.ftn', addFirstSlash(mc.getAttr(f + '.ftn')), 
>> type='string')
>>
>> om.MSceneMessage.addCallback(om.MSceneMessage.kBeforeSave, 
>> mf_MSceneMessage_BeforeSave_CB)
>>
>>
>>
>>
>>
>> -- 
>> 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 python_inside_maya+unsubscr...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/python_inside_maya/d2c24e10-41f8-4b90-a05e-38369c42b8f5%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> -- 
> Best, 
>
> -M
> -- 
> 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 python_inside_maya+unsubscr...@googlegroups.com .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/python_inside_maya/CA%2B7MZWtvrU3JSdZQ3v9PJTGu7QE27K9RCD2n1CwTYhK%2BZchL6A%40mail.gmail.com
>  
> 
> .
> 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 python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/fe883a81-17dd-465f-8023-3294641fb230%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] changing path to references witha callback

2017-11-29 Thread Mahendra Gangaiwar
I think better approach here would be make use of "dirmap" command, so you
could map Linux to Windows and vice versa..

Something like this:

dirmap("//server", "/server");
dirmap("/server", "//server");

Try running above command, and open file, all references and texture paths
should remapped automatically by Maya.

On Wed 29 Nov, 2017, 9:34 PM Michał Frątczak,  wrote:

> Hi
>
> We move maya scenes between linux and windows machines.
> When linux references a file it uses UNC paths like:
> /server/project/file.ext
> whereas windows needs double slash in front: //server/project/file.ext
>
> I have a MSceneMessage.kBeforeSave callback that fixes paths on texture
> nodes (ensures leading //).
> I remember having done similar thing with references too, but I lost the
> script and can't recall details... any hints how to change path to
> reference ?
>
> Here is my texture fixing code:
>
> def addFirstSlash(i_str):
> if i_str[0] == '/' and i_str[1] != '/':
> return '/' + i_str
> return i_str
>
> def mf_MSceneMessage_BeforeSave_CB(*args, **kwargs):
> for f in mc.ls(type='file'):
> mc.setAttr(f + '.ftn', addFirstSlash(mc.getAttr(f + '.ftn')), type
> ='string')
>
> om.MSceneMessage.addCallback(om.MSceneMessage.kBeforeSave,
> mf_MSceneMessage_BeforeSave_CB)
>
>
>
>
>
> --
> 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 python_inside_maya+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/d2c24e10-41f8-4b90-a05e-38369c42b8f5%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
-- 
Best,

-M

-- 
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 python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CA%2B7MZWtvrU3JSdZQ3v9PJTGu7QE27K9RCD2n1CwTYhK%2BZchL6A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] changing path to references witha callback

2017-11-29 Thread Michał Frątczak
Hi

We move maya scenes between linux and windows machines.
When linux references a file it uses UNC paths like: 
/server/project/file.ext
whereas windows needs double slash in front: //server/project/file.ext

I have a MSceneMessage.kBeforeSave callback that fixes paths on texture 
nodes (ensures leading //).
I remember having done similar thing with references too, but I lost the 
script and can't recall details... any hints how to change path to 
reference ?

Here is my texture fixing code:

def addFirstSlash(i_str):
if i_str[0] == '/' and i_str[1] != '/':
return '/' + i_str
return i_str

def mf_MSceneMessage_BeforeSave_CB(*args, **kwargs):
for f in mc.ls(type='file'):
mc.setAttr(f + '.ftn', addFirstSlash(mc.getAttr(f + '.ftn')), type=
'string')

om.MSceneMessage.addCallback(om.MSceneMessage.kBeforeSave, 
mf_MSceneMessage_BeforeSave_CB)





-- 
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 python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/d2c24e10-41f8-4b90-a05e-38369c42b8f5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.