XRef Manipulation
-
On 07/08/2018 at 11:53, xxxxxxxx wrote:
Hi guys !
I am in the process of implementing a fairly complex Asset instance management for C4D using our pipeline. I am looking into using C4D's XRef. Very happily surprised it supports referencing Alembics !
I'm fighting with some issues though. Most of them have some references to them on this forum, but the topics are old, so i'm hoping some things have changed.First, is there still no way to prevent a dialog with import options to show up when changing the path to a reference ? Can we hack around that ?
Second, it seems that deleting a reference using python (deleting the root object with Remove() ) leaves some sort of trace in the XRef Manager. Should i be deleting them using something else ?Overall it seems XRef are quite finicky to manipulate from code, this is quite limiting from a pipeline standpoint. Would i have more luck implementing some sort of custom command for what i need in C++ or would i have the same problems ?
Thanks !
-
On 08/08/2018 at 08:23, xxxxxxxx wrote:
Hi,
unfortunately there were no changes to Xrefs in this regard.
-
No, there's no way to avoid this dialog, sorry.
-
The problem is, that Xrefs need to do a whole bunch of monitoring in the background, mainly reacting to user interactions. And internally the Xrefs do not only consist of just the Xref object, but there's also an Xref document and a SceneHook doing quite a lot of work. If Xrefs now get manipulated by the API without user interaction, things tend to get out of sync easily. So for the removal of an Xref object you can work around by first selecting the object and then using c4d.CallCommand(c4d,IDM_DELETE) to delete the object. Unfortunately at the price of an additional undo step being created implicitly.
In C++ one has the same issues with Xrefs as in Python.
A few general rules of thumb with Xrefs:
- Do all parameter changes as user interaction (DESCFLAGS_SET_USERINTERACTION)
- Options in Xref Options dialog can not be manipulated via API -
-
On 09/08/2018 at 13:04, xxxxxxxx wrote:
Thanks you very much for these details. It's too bad there's no way around it, it would be very useful otherwise. I guess for the moment i'll just write a pseudo reference thing for Alembic files. Do you think in a future version it would be possible to have more API access to XRefs things ? This would make our lives a lot easier at the studio
The delete command for XRefs works like a charm by the way !
I have other questions, i'm wondering if I should make a new topic eveytime or not, but anyway :
How would you go at creating a callback everytime a document is saved ? (CTRL+S). I read about CoreMessage but could not find a hook for this anywhere.Again, thanks a lot !
-
On 10/08/2018 at 08:33, xxxxxxxx wrote:
Hi,
in general we prefer new threads for new topics, yes.
In Python there's unfortunately no good way to detect saving of a document. In C++ you can implement a SceneHook and react to MSG_DOCUMENTINFO, There are different types for before and after saving of a document.
If you tell us, what you want to achieve, maybe we can come up with another idea.