0
$\begingroup$

I know the trick of hovering my mouse over the function I want to perform to reveal its corresponding python code, but i'm not sure how to use this code, for example from vse: menu playback>audio scrubbing and which bit to use:

Scene.use_audio_scrub
bpy.data.scenes["Scene"].use_audio_scrub

I have also looked here, but am none the wiser.

I tried placing the code in the console but got the error message:

>>> bpy.data.scenes["Scene"].use_audio_scrub = true
Traceback (most recent call last):
  File "<blender_console>", line 1, in <module>
NameError: name 'true' is not defined
$\endgroup$
1
$\begingroup$

The error occurs because true is not a python keyword. You meant to use True (capitalized).

Use bpy.context.scene, this gets the active scene instead of a scene name "Scene".

The code usually refers to the operation or the datablock, which the button or UI controls changes or calls.

The following code works.

import bpy

# Next two lines assign absolute values ("True" / "False")
# bpy.context.scene.use_audio_scrub = True
# bpy.context.scene.use_audio_scrub = False

# method changing the use_audio_scrub state
def Custom_Toggle_Audio_Scrub():
    bpy.context.scene.use_audio_scrub = not bpy.context.scene.use_audio_scrub

# call and execute the method
Custom_Toggle_Audio_Scrub()
|improve this answer|||||
$\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.