So, has anybody found a nice way to remap path to a referenced file based 
on referenceNode attributes?
It seems referenceNode is not accessible inside kBeforeCreateReferenceCheck 
callback


On Thursday, December 30, 2010 at 3:12:58 PM UTC+1, Pierre A wrote:
>
> Thanks for the link, actually I had already bumped into that one.
>
> So let's recap the issue: if the file path does not lead to an existing 
> file, the reference is not created.
> This behavior is the same with buildLoadSettings set to True in the 
> cmds.file function. And when there is no reference node in the scene, 
> you've lost all your data. Too late.
>
> Regarding the callbacks, only MSceneMessage.addCheckFileCallback, 
> and MSceneMessage.addCheckCallback can be used, with 
> the kBeforeCreateReferenceCheck enum. These callbacks will be triggered 
> before reference creation.
>
> If you parse a .ma file, there are at least three lines regarding 
> reference creation:
> 1/ file -rdi 1 -ns "REF_NS" -dr 1 -rfn "REF_NAME" "/path/to/file.ma";
> 2/ file -r -ns "REF_NS" -dr 1 -rfn "REF_NAME" "/path/to/file.ma";
> 3/ createNode reference -n "REF_NAME";
>
> The first line does not trigger the remap path popup ("abort..." - "skip" 
> - "browse..." buttons). The second one does.
> addCheckFileCallback and addCheckCallback are called just before 2/ is 
> executed.
>
> If you want to monitor the reference node creation, this step is executed 
> after the path check. It's the line 3/. You can have callbacks thanks 
> to MDGMessage.addNodeAddedCallback, but it's useless for me.
>
> Among MSceneMessage.addCheckFileCallback 
> and MSceneMessage.addCheckCallback, only addCheckFileCallback is relevant 
> here because you can modify the MFileObject passed as argument of the 
> callback (by reference).
>
> http://download.autodesk.com/us/maya/2011help/API/class_m_scene_message.html#5e6feb8445b04b7277c0a425a613444f
>
> http://download.autodesk.com/us/maya/2011help/API/class_m_message.html#c9d1a728216d6a9618052ad122710fa8
>
> Note: Don't forget to set retCode to True with 
> OpenMaya.MScriptUtil.setBool(retCode, True). The signature of setBool is 
> bool& but it seems to accept a bool*
>
> In my particular case, I need the reference node name (rfn) to be able to 
> remap the bad path to an existing one. Unfortunately, I have not found a 
> way to get this piece of info in a straightforward manner.
> I have tried to use the MCommandMessage.addCommandCallback in order to see 
> which 2/ "file -r -ns .... " is executed, but the callback is called after 
> the addCheckFileCallback.
> Of course, the 1/ "file -rdi 1 -ns ... " are executed 
> before addCheckFileCallback, and I could assume that 2/ commands will be 
> called in the same order than 1/.
> Another hack would be to directly parse the .ma file and build a list/dict 
> for the list of 2/ command lines.
> Then, by incrementing an index for each addCheckFileCallback call, I could 
> match the reference name with the corresponding path.
>
> The first solution proposed by Christian is clearly simpler, providing 
> that the renaming process is not harmful. Unfortunately I can not overwrite 
> the maya files.
>
> I think I'll go with a .ma parsing for 2/ lines & building list of 
> reference node name.
>
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/b38c7e80-4d56-483c-9f7a-9a83fde7bec9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to