Let's say I've created a scene property named a:

bpy.types.Scene.a = bpy.props.IntVectorProperty(
    default=[1, 2]

And now I would like to update it's size to something else.

  • How can I do that?
  • Do I have to override the property? What if instead of a single property I have a PropertyGroup and I want to update an IntVectorProperty that belongs to the group?

Have you seen Property Definitions? IntVectorProperty have other parameters to define, among which no "size"!

You can create a Custom property from PropertyGroup:

class CustomProperty(bpy.types.PropertyGroup):
    name: bpy.props.StringProperty(name="Name", default="Some name")
    description: bpy.props.StringProperty(name="Description", default="Frequencies")
    size: bpy.props.IntProperty(name="Size", default=2)

To update any property just assign some value:

bpy.types.Scene.a = 3
| improve this answer | |
  • $\begingroup$ RUben: I don't think you read the question. Also your first statement is wrong, IntVectorProperty's do have size, which defaults to 3. Read carefully the link you shared :) Also I don't see how the rest of your answer addresses my question, I know how to create IntVectorProperty's, I just don't know how to change them dynamically to have different sizes. I want to have the same experience we have with list's in Python. Anyway, I appreciate the time you took to try and answer, but please fix your answer, that would be great :) $\endgroup$ – gmagno Sep 11 '19 at 17:21
  • $\begingroup$ my mistake - part of the parameters in manual is hidden behind the scroll $\endgroup$ – RUben Sep 12 '19 at 8:28
from bpy.props import CollectionProperty, IntVectorProperty, StringProperty
from bpy.types import AddonPreferences

classes = []

def CreatVectorProp(size, name, vectortyp):
    exec("bpy.types.Scene.%sproperty_%s = %sProperty(size= size)" % (vectortyp.lower(), name, vectortyp)) 
    return "bpy.context.scene.%sproperty_%s" %(vectortyp.lower(), name)

def AddNewElementToCollection():
    new = bpy.context.scene.MyCollection.add()
    new.address = CreatVectorProp(10, "MyIntVector", "IntVector")
    new.otherprops = "other stuff"

def RemoveElementfromCollection(index):
    exec("del bpy.types.Scene.%s" % bpy.context.scene.MyCollection[index].address.split(".")[-1])

def UpdateVector(index, newsize):
    exec("del bpy.types.Scene.%s" % bpy.context.scene.MyCollection[index].address.split(".")[-1])
    bpy.context.scene.MyCollection[index].address = CreatVectorProp(newsize, "MyNewVector", "IntVector")

def AssignValues(index, values):
    exec("%s = values" % bpy.context.scene.MyCollection[index].address)

def GetValues(index):
    return eval(bpy.context.scene.MyCollection[index].address)

class MyProperty(bpy.types.PropertyGroup):
    address : StringProperty()
    otherprops : StringProperty()

def register():
    for cls in classes:
    bpy.types.Scene.MyCollection = CollectionProperty(type= MyProperty)

def unregister():
    for ele in bpy.context.scene.MyCollection:
        exec("del bpy.types.Scene.%s" % ele.address.split(".")[-1])
    del bpy.types.Scene.MyCollection
    for cls in classes:

Something like this should do the trick. (Tested on version 2.83.3)

| improve this answer | |
New contributor
Rivin is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • $\begingroup$ If you also want to delete the VectorProperty from the context add exec("del bpy.context.scene['%s']" % bpy.context.scene.MyCollection[index].address.split(".")[-1] under each exec("del bpy.types.Scene.%s" % bpy.context.scene.MyCollection[index].address.split(".")[-1]) $\endgroup$ – Rivin 10 hours ago

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.