1
$\begingroup$

I learned to use

object.path_from_id(property)

to obtain the path for my fcurves. But when I did this:

object.path_from_id('rotation_euler')
output: 'rotation_euler'

I started to wonder

on other properties I tested it behaved exactly the same
so, why should I even bother with this method?

$\endgroup$
4
$\begingroup$

It's useful for more complex situations than this. Let's say you have an object with a subsurf modifier, and you pass a reference to that modifier to some function:

mod = bpy.context.object.modifiers['Subsurf'] somefunc(mod)

That function can now figure out the path of a property of the subdivision surface, like this:

def somefunc(mod): print(mod.path_from_id('name')) # this outputs 'modifiers["Subsurf"].name'

Here is another practical example I just encountered. I want to create a driver for a specific property on the active sequencer strip. The driver needs to be defined on the scene itself, and I need to get the path for the property to drive:

se = C.scene.sequence_editor se.active_strip.transform.path_from_id('offset_x')

This outputs 'sequence_editor.sequences_all["2017-07-06T11-04-11+0200.webcam"].transform.offset_x', which is what is needed for the driver.

$\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.