We could add a python `sort` function to rna, nothing inherently hard about that,
But its a fair bit of grunt work. - Modifiers cant _always_ be re-ordered, so rna sort would need to be able to raise exceptions into Python (most likely using reports). - Each different list type would need its own sort function. (though we could have a generic one for arrays and ListBase which could be used in most cases). - Should support Python like operations key=lambda, compare function, reverse=bool. etc. On Wed, May 14, 2014 at 5:11 PM, CoDEmanX <[email protected]> wrote: > Some support re-ordering by re-assignment, just like regular python lists: > > m = Object.materials # assuming there are only two! > m[0], m[1] = m[1], m[0] > > The Modifier stack does not support this. There is no other way to > re-order modifiers than to use operators. > > CollectionProperty() creates objects from <class > 'bpy_prop_collection_idprop'>, which comes with a handy method move(). > You give it the index of which element you want to move, and another > index for the target position to swap these two elements. > > > Am 14.05.2014 04:02, schrieb Tamito KAJIYAMA: >> Hi, >> >> Is there a general way to re-order items of bpy_prop_collection >> in Python? For example, how can we swap two modifiers in >> bpy.context.object.modifiers? Since the collection is read-only, >> the general Python sequence protocol seems not to work. >> > _______________________________________________ > Bf-python mailing list > [email protected] > http://lists.blender.org/mailman/listinfo/bf-python -- - Campbell _______________________________________________ Bf-python mailing list [email protected] http://lists.blender.org/mailman/listinfo/bf-python
