Hi,
following problem described from user point of view:
-
Project A gets saved via "Save Project with Assets..." (all asset references get converted to relative references, all assets get transferred into the target tex folder. All working nicely via
MSG_GETALLASSETS
+MSG_CLEARSUGGESTEDFOLDERS
messages). -
User wants to merge above saved Project A into Project B. Problem: No asset reference is working, because this operation does not seem to take conversion of asset references from relative to absolute into account, nor does it copy any assets over into the target project's folder.
I reproduced this behavior in versions R17 to S24. I'd probably rather call this a bug than a missing feature, because in other places C4D solves this correctly (e.g. when copy/pasting from another document) by asking the user, what to do with the participating assets.
I would very much like to solve this issue for a plugin, where MergeDocument()
gets used quite heavily. Preferably without copying assets around manually. And also without trying to fix all asset references manually inside a document. It seems as if MSG_RENAMETEXTURES
could be coming in handy and while the symbol is not documented in Python docs, it is yet available.
But trying to do a broadcast like so:
msg = {'oldname' : path, 'newname' : pathNew, 'doc' : docToMerge, 'changecnt' : 0, 'noundo' : True}
result = docToMerge.MultiMessage(c4d.MULTIMSG_ROUTE_BROADCAST, c4d.MSG_RENAMETEXTURES, msg)
I agree, it was already a bit far fetched to hope to "emulate" the needed RenameTextureMessage
stucture via a dictionary. So I was not too surprised to see it not working. Yet, it locks up C4D completely, which perhaps is a bit too hard of a sentence for trying to figure out, how an undocumented message may work. ;)
And using MultiMessage(c4d.MULTIMSG_ROUTE_NONE)
or MultiMessage(c4d.MULTIMSG_ROUTE_ROOT | c4d.MULTIMSG_ROUTE_DOWN)
instead does not lock up C4D, but simply seems to do nothing.
So, I guess, my actual question is: Is it possible to use MSG_RENAMETEXTURES
from Python at all? And if so, how?
I assume it is probably not, as there seems to be no way to properly provide RenameTextureMessage
data via Python.
Maybe I should also explain why I I'd prefer to solve this issue without manually copying assets (a) and without trying to manually fix the asset references inside a document (b):
a) This is related to a second thread I will be posting in a minute. It simply seems not to be completely trivial to identify all assets really in use in a document (I do know about GetAllTextures()
).
b) This seems to be an even harder task. Already for all built-in stuff it would mean to iterate all branches and I think, I remember from the past that it can be non-trivial to identify all references to assets. Yet for built-in stuff, this could work by somehow examining descriptions of all entitities. But taking for example 3rd party renderers into account, I could imagine such references being hidden in some custom nodal shader networks, making this even more complicated.
Thanks in advance for taking a look.
Cheers