Hey @ThomasB,
so, I had a look and figured it out. When you diff the two objects from my file, there are quite few differences (as I was not 100% faithful in copying all values), but the culprit is this:
[image: 1783349248850-cef8fb22-88d1-4073-8b29-1e2958c0db14-image.png]
The RS Light uses a standard light to accomplish its VP representation. When you disable the 'Illumination' checkmark, the RS Light GetVirtualObjects will simply return a null object, i.e., the behavior you experienced. I filed a ticket for this (ITEM#651586 Inconsistent Redshift Light 'Make Editable' behavior), as I would consider this so unintuitive that it borders on a bug. But this is outside of the SDK/Cinema 4D domain, so I cannot just fix it myself.
In Python, there is currently no way to fix this on your side. The message MSG_CURRENTSTATE_END is not wrapped for Python (with it you can manipulate the output of a "Make Editable" action before it is inserted). The other route, the build flags on HierarchyHelp are also not possible in Python either, because HierarchyHelp is also not wrapped for Python.
But I just changed the latter route, and in the next major update you will be able to react to build flags. There will also be a new code example named py-objectdata_buildflags_2027 which showcases this feature. You can then react to your object being made editable, built for rendering, built for export, etc. and react by changing its output.
In your case you would then probably not disable the illumination when your object is being made editable. So, for now, you either have to live with the behavior, or turn on "preview > illumination".
Cheers,
Ferdinand
Result
The output, i.e., diff, with the offending line highlighted.
[image: 1783418649677-d0a8e14c-d913-4990-9ec5-29e4a5150cf3-image-resized.png]
Code
This assumes my scene from above with everything deleted but the two objects.
import c4d
import mxutils
import difflib
doc: c4d.documents.BaseDocument # The currently active document.
op: c4d.BaseObject | None # The primary selected object in `doc`. Can be `None`.
def main() -> None:
"""Called by Cinema 4D when the script is being executed.
"""
data: list[str] = [
mxutils.GetParameterTreeString(node)
for node in mxutils.IterateTree(doc.GetFirstObject(), True)
]
# Diff the first two strings in the list and print the result to the console.
if len(data) < 2:
return c4d.gui.MessageDialog("Not enough data to perform diff.")
a: str = data[0]
b: str = data[1]
diff: list[str] = list(difflib.unified_diff(a.splitlines(), b.splitlines(), lineterm=''))
if not diff:
print("No differences found.")
print("\n".join(diff))
print("\n\n" + "=" * 80 + "\n\n")
print(a)
print("\n" + "-" * 80 + "\n")
print(b)
c4d.EventAdd()
if __name__ == '__main__':
main()