Change(replace) file within reference

2019-08-24 00:29发布

问题:

I need to replace an OLD file with a NEW file within a reference. There is a referenceEdit command but no flags for replacing a file.

so ideally I need sth like:

cmds.referenceQuery( myReference, e=1, file=NEW )

回答1:

You should be able to replace references by using the file command.

Assuming your reference node's name is known (otherwise you can retrieve it via referenceQuery) and the name is myReferenceRN, you can do:

from maya import cmds
cmds.file("/path/to/new/reference/file.mb", loadReference="myReferenceRN")

This will update the file path which myReferenceRN currently points to, with the one you specify as the first argument of the file command (in this case, /path/to/new/reference/file.mb).



标签: python maya