Notifications
Clear all

[Closed] Test for read-only property?

Is there a way to test if a variable is read only? I am trying to do mass amounts of getProperty/setProperty calls using getPropNames, but some of the properties I’m running into are read only. I’d rather be able to do a simple automated test rather than manually excluding property names or falling back on a try/catch. A try/catch might be the way to go, but I want to avoid it if possible because of the slowdown (noticing major slowdown already and I’m testing on something very small in comparison to what I’m planning to be using this for).

I asked something similar in the past about making sure the value type being assigned to a property is actually valid, and the best solution seemed to be parsing the stream value returned by showProperties. I’m not sure this will work in this situation because of inconsistencies between the formatting of showInterfaces and showProperties. I think read|write is missing all together from showProperties actually.

Anyways, any suggestions would be great. Thanks!

2 Replies

I think try/catch is your only option. You could, however, keep a cache of parent classes and property names, and store their read/write, animateable, value type, etc. in that cache.

That way if a user selects a sphere for the very first time, things get cached, and any other sphere selection/parsing can just use the cache.

I did indeed expect a read/write check somewhere along the lines of isPropertyAnimatable, but alas.

Nuts! It certainly would make things a lot easier. Ah well. Thanks for having a look Richard!