Page MenuHome

Library Override: can't add to Collection properties
Closed, ArchivedPublic

Description

System Information
Operating system: Windows-10-10.0.19041-SP0 64 Bits
Graphics card: GeForce GTX 770/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 452.06

Blender Version
Broken: version: 2.92.0 Alpha, branch: master, commit date: 2020-10-23 11:34, hash: rBe4728d0a167c
Broken: version: 2.91.0 Alpha, branch: master, commit date: 2020-09-21 19:29, hash: rB8eda3ddc4f04
Worked: version: 2.91.0 Alpha, branch: master, commit date: 2020-09-16 21:05, hash: rB27660b3cd90d

Short description of error
When an addon uses a CollectionProperty to add data to things (example: bones), it uses [collection_path].add() to add the container for the data.
When the owner (bone/object/etc) of that parameter (CollectionProperty) is linked and a Library Override, Blender returns an error when trying to add to the collection.

Exact steps for others to reproduce the error


cube-linked.blend Is the test file.
cube.blend is the file being linked

Open cube-linked.
Run the script on the left in the Text Editor
Copy the test code to the Python Console on the right bpy.context.object.col.add()
The Torus object (not linked) will run as expected.

Select the cube (library override) and run the test code again
Blender will say TypeError: bpy_prop_collection.add(): not supported for this collection

Event Timeline

Philipp Oeser (lichtwerk) closed this task as Archived.Oct 27 2020, 9:59 AM
Philipp Oeser (lichtwerk) claimed this task.

For this to work, you have to flag the CollectionProperty with USE_INSERTION

"Allow users to add new items in that collection in library overrides"

bpy.types.Object.col = bpy.props.CollectionProperty(
    type=propc,
    options={'LIBRARY_EDITABLE'},
    override={'LIBRARY_OVERRIDABLE', 'USE_INSERTION'},
)

It is a bit hidden, but not a bug. Will close (but feel free to comment again if issues persist)

Thank you.
I haven't tested yet but I'm sure it'll work.

With 'USE_INSERTION' you can add new items to the override collection prop, but if you save and reopen the file, the items are not saved.
You can try it with the addon "Selection Sets".

Is it a bug? Probaly is the correct way (you can override and modify the props, but not their structure... I think...)