I was processing vMaterials_2/Paint/Carpaint/Carpaint_Shifting_Flakes.mdl (from vMaterials2 2.4.0-373000.4039) which contains, beside the material export “Carpaint_Shifting_Flakes”, a series of other materials that override the latter’s default parameters, for instance “Green_Aquatic”.
Exporting this material to and importing it from an .mdle file is working, but I need to restore the original module and material name for further processing downstream rather than the renamed “main”. To my understanding, this is exactly what the ::anno::origin annotation is used for (in Sec 25.3 “Container content”, item 9, the spec states):
If a declaration in the main module is the result of a copy or refactoring operation of another declaration, the origin() standard annotation (Section 18) shall be set to this original declaration, or the value of its origin() annotation if it exists. […]
However, after reloading the exported .mdle, the origin annotation was reading “::vMaterials_2::Paint::Carpaint::Carpaint_Shifting_Flakes::Carpaint_Shifting_Flakes” when (if I’m not mistaken) it should have been “::vMaterials_2::Paint::Carpaint::Carpaint_Shifting_Flakes::Green_Aquatic”.
Is that behaviour intended? That is, does the origin annotation always refer to a material’s parent (or even the root parent) material rather than itself?
I noticed this issue for SDK version 367100.1652 (and was able to reproduce it with version 373000.3036).
thanks for the report, we are looking into it. To better understand your use case, could you explain why it is important for you to see …::Green_Aquatic instead of …::Carpaint_Shifting_Flakes?
Are you using the API to create the MDLE (or the mdlm tool)? With the API you could pass the origin annotation yourself as a workaround for the time being.
the software I’m working on provides a material editor/library in the GUI where the material names are used as labels for identification/distinction. Hence, when a session is saved and loaded at a later point in time (each material is stored in an individual MDLE), the material names must remain identical.
For MDLE generation, I’m using the MDLE API; my current approach is to attach a text file containing my custom origin annotation to the user data. Could you show me some sample code for attaching the origin annotation? I tried this before but couldn’t make it work.
thanks for the explanation of your use case. The attached patch extends one of the unit tests and demonstrates how to set your own value for the ::anno::origin annotation.
thanks for the code example. Unfortunately, it did not resolve the issue; however, with my workaround in place, I can wait for the 2024.1 release. Thanks for looking into this issue!