I have a propertygroup class called "Variants" from which I created several variant objects. Now I'm struggling to add these existing objects to a collection in another class.
class variantStates(bpy.types.PropertyGroup): variantState: bpy.props.StringProperty() class variant(bpy.types.PropertyGroup): variantType: bpy.props.StringProperty() variantName: bpy.props.StringProperty() # List of all possible states variantStates: bpy.props.CollectionProperty(type=variantStates) class variantList(bpy.types.PropertyGroup): variantRef: bpy.props.PointerProperty(type=variant) class variantSet(bpy.types.PropertyGroup): # This is a Variant Set. It will contain several variants and trigger them all together variantSetName: bpy.props.StringProperty() # Here I want to add the existing variants when I create the set variantSetVariants: bpy.props.CollectionProperty(type=variantList)
here is the snippet from the operator that should later add the variants to the set:
for variant in var: addedVariant = newSet.variantSetVariants.add() addedVariant.variantRef = variant
I use the same approach as with adding the states to the variant early, but now it tells me that the pointer is read-only. And I only get a new empty variant added to the list. I guess I'm not really knowing what the pointer does. How can I achieve this? I was following the logic of this post where this is done with a pointer to "bpy.types.Object" and it works perfectly: