0
$\begingroup$

I know it's probably not the most elegant, or even a usable, solution, but is it possible to use a keyboard shortcut, say pageUP in a python blender script?

OR find out the code behind the shortcut, like one can do elsewhere in blender, like a button's code for example.

I have been looking in the input user preferences and hovered over the shorcut , which gives me:

keyMapItem.map_type
bpy.data.window_managers["WinMan"] ... map_type 

But i'm not sure how to use this, in a script, to give me the shortcut "page up" functionality.

$\endgroup$
7
  • 2
    $\begingroup$ What is "blender script"? Is it the Text editor or Python console or is this about adding a shortcut with python script? What function you want to make a shortcut for? $\endgroup$ Jan 20, 2017 at 14:20
  • 1
    $\begingroup$ I don't think you want to use the shortcut, you want to use the tool that the shortcut activates. $\endgroup$ Jan 20, 2017 at 14:27
  • $\begingroup$ I have a series of one frame movie strips, which I want to iterate through and extend each strip from one frame to 10 frames. I use the pageUP and pageDpwn shortcut to manually iterate through them, then select them and change the length from one to ten. I was looking to automate this process with a python script within Blender. $\endgroup$
    – reggie
    Jan 20, 2017 at 14:40
  • $\begingroup$ I cannot find the syntax that relates to the shortcut. I know to hover over a button, or whatever, to get the python code, but am stuck for shortcuts. $\endgroup$
    – reggie
    Jan 20, 2017 at 14:42
  • $\begingroup$ @reggie Go to the user preferences > INPUT and search for "Page Up" with the mask set to Key Binding $\endgroup$
    – Leander
    Jan 20, 2017 at 16:21

1 Answer 1

5
$\begingroup$

It would be better(and probably easier) to do this directly rather than using trying to use the keyboard shortcuts in the code. Try this:

seqs = bpy.context.scene.sequence_editor.sequences_all
for seq in seqs:
    seq.frame_final_duration = 10

Or if you want to just modify selected strips:

seqs = bpy.context.scene.sequence_editor.sequences_all
for seq in seqs:
    if seq.select:
        seq.frame_final_duration = 10

Or if you want to just modify the strips based in their length:

seqs = bpy.context.scene.sequence_editor.sequences_all
for seq in seqs:
    if seq.frame_final_duration == 1:
        seq.frame_final_duration = 10
$\endgroup$
7
  • $\begingroup$ I was trying to use the shortcut to jump through my clips in the scene, so I could select the clips that are only one frame long. I have other longer clips in there too, sorry didn't make myself clear. $\endgroup$
    – reggie
    Jan 21, 2017 at 8:47
  • $\begingroup$ Your answer is spot on for my comment (3rd comment down)! $\endgroup$
    – reggie
    Jan 21, 2017 at 8:50
  • $\begingroup$ Could your code be modified to only select the clips that are 1 frame long and ignore the others? $\endgroup$
    – reggie
    Jan 21, 2017 at 8:54
  • $\begingroup$ Added to answer. $\endgroup$
    – cmomoney
    Jan 21, 2017 at 11:55
  • 1
    $\begingroup$ Whoo, this does what I need! Thanks cmomney. I'm a little curious, however, if one can actually use shortcut keys in some way in a script? $\endgroup$
    – reggie
    Jan 21, 2017 at 12:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .