Hi,
I want to change the order of an item in the comp.Properties list using the Python API.
The problem is that the Properties list is read-only and so I can’t use the normal way in Python to change the index of an element in a list:
a = [1,2,3]
b = a[1]
a.remove(b)
a.insert(0,b)
will result in [2,1,3]
Does anyone have an idea how to make a change like this in the properties list?
Thanks!
No idea other than deleting and recreating the properties in the preferred order. It seems like vcComponent.Properties now gives you the 10 default, hardcoded properties as well, so you cannot change the order of those.
from vcScript import *
comp = getComponent()
props = comp.Properties[10:]
Not sure if you delete and recreate the properties if the references in other objects will break. For example, Block.Length = “MyCustomProperty” is a reference to a property of that name and gets its value. So I don’t know if the memory location would be updated and the main application responds to the error caused when you delete the referenced property.
Thanks for your reply, I just tested what you described and this results in “Expression needs recompilation” so this doesn’t work.
Well I have a answer to my question: “Not possible”
Thanks for your help