0
$\begingroup$

I am creating a new addon for Blender, and in that addon I need to access Object's properties like location, scale, etc. I know that I can access them through interface like: object.location, object.scale

It's good if I know what property I need in advance, but I don't know what property I will need to access, it can be location, material of the object, etc. And I need to access them like: object["location"], object["scale"]

I tried that way, but I can access only custom properties, not properties like location or scale. Is it possible to access Object's location or material using key?

$\endgroup$
1
$\begingroup$

Yes, using getattr: https://docs.python.org/3.5/library/functions.html#getattr

location = getattr(object, "location")
$\endgroup$

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.