[Bf-python] Fileselector [new: + bg mode]

Willian Padovani Germano wgermano at ig.com.br
Sat Mar 19 17:35:07 CET 2005


Willian Padovani Germano wrote:

> Paolo Colombo wrote:
>
>> Is there a way to call the filesector from a script running in a 
>> scriptlink?
>
> No, scripts that call the file/image selectors need to have their 
> global dicts preserved until the selector callback finishes.
>
> But I'll work on letting scripts run other scripts (a 
> Blender.Exec(script) function, probably), so that and other things 
> should become possible.

Done. Check the Blender.Run(script) function committed yesterday (forgot 
to mention it in the cvs commit msg).  It can be used to execute files 
in the file system or Blender Texts, like the "blender -P script" command.

So, if you need a file selector in a scriptlink, for example, write a 
Blender Text to open the file selector:
#---- Text
def f(filename):
  # do something with the filename

Blender.Window.FileSelector(f)
#----

and in your script link call it with Blender.Run(Text).

The script will run in its own context, with its own global dictionary, 
as if called with ALT+P.

Talking about blender -P, there are some updates for a bg mode now, 
too.  Check the API_intro.py doc or here:
http://projects.blender.org/tracker/?func=detail&atid=125&aid=1655&group_id=9

I made a few changes to Joe Gilbert's sceneRender code (without asking 
first, sorry Joe!) to allow bg rendering from a script and also made 
some redraw functions, file/image selectors, progress bar, etc. check if 
we're in bg mode and not work then.  More testing is needed, as always.

-- 
Willian





More information about the Bf-python mailing list