-5
$\begingroup$

How to

1: Add a file browser to a a UI panel to get user selected file path & assign to var.

Useful: How can i open a file select dialog via python to add an image sequence into VSE?

2: How to have button that executes a specific part of a script.

(Copying code from Blender's interface meant that the filepath that I ended up using was one also used by Render>Output.)

Best source I have seen in 4 days of searching https://blenderapi.wordpress.com/2011/09/26/file-selection-with-python/#comment-4

Useful: http://wiki.blender.org/index.php/Dev:2.5/Py/Scripts/Cookbook/Code_snippets/Interface

$\endgroup$
  • 1
    $\begingroup$ Might be a good idea adding the panel to the sequencer: bl_space_type='SEQUENCE_EDITOR' bl_region_type = 'UI'. This should be a great starting point. $\endgroup$ – p2or Dec 6 '15 at 11:07
2
$\begingroup$

Many operators define a poll method that determines when it is able to be used. If this method returns False then the operators execute method will not be run and any UI button for the operator will be greyed out.

In your example of using the sequencer.sound_strip_add operator, it's poll method will only return True if the VSE is the active editor.

That means you want to put your panel into the VSE editor not the 3D View.

| improve this answer | |
$\endgroup$
  • $\begingroup$ OK, in that case, what I need is a filebrowser button on my panel in TOOLS, which the script then uses to know where the audio files are. just like PROPERTIES>>>RENDER has a folder icon ... that's what I need. The main script does the loading itself, but needs the user to tell it where the files are. $\endgroup$ – The Beachdancer Dec 6 '15 at 15:23
  • $\begingroup$ blender.stackexchange.com/q/2382/935 $\endgroup$ – sambler Dec 7 '15 at 7:51
  • $\begingroup$ After another day of researching this I have found a way to put a file browser launcher on the panel, but the lack of documentation of the data structure means that I am storing the filepath in an inappropriate place. I found a way to store it within the VSE data structure, but that only worked if there was already a clip in the VSE. The atrocious documentation for scripting turned a 1 hour job into a 1 day job. I will launch a simpler question "Scripting, panel, UI, how to add a file browser" $\endgroup$ – The Beachdancer Dec 7 '15 at 12:49
-1
$\begingroup$

File browsers are explained in this link: Scripting, panel , UI: button to load sound file, button to execute body of script

Clickable buttons are created like this:

   def draw(self, context):
         self.layout.row.operator( text="Execute me") #is a clickable button

   #when clicked Blender runs whatever you code in...

    def invoke(self,context,event)
| 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.