[Bf-python] Blender -b and Scenes

Campbell Barton cbarton at metavr.com
Wed Mar 22 05:39:00 CET 2006


Indeed there are cases where a scene may not be needed, all the same. if 
it can save us from adding in 40 or so exceptions its probably worth 1 
check and a scene adding.
Also. unless we want to check for G.scene in every function it could be 
hard to know which blender functions use G.scene or not.
Id rather all python functions assume G.scene isnt NULL and deal with 
this corner case by making a scene.

wont do anything yet :) - but it does not seem that Blender its self 
does not support G.scene==NULL even if BPython could.

By the way. the creation of a blender scene would be done when Blender 
loads the "import Blender" Blender module for the first time. so its 
only ging to effect
blender -b -P blah.py  # type functions.

If the user encounters the error. "Sorry No BPyScene, first create a new 
scene" all they are going to do is add a Scene.New() to there script. so 
one way or another there needs to be a new scene.

Anyhow, Ill let you guys kick this one about.
- Cam




Toni Alatalo wrote:
> On Wednesday 22 March 2006 04:37, Willian Padovani Germano wrote:
>   
>> pointers (good practices, not just for bg mode), but creating a scene
>> iff G.scene is NULL AND we're in bg mode may be a good solution in this
>> case (others here: opinions?).
>>     
>
> i think it can well make sense to always have a scene.. like said there is 
> always one when Blender is running with the GUI, and often the objects of 
> interest are best accessible via / in a scene too. 
>
> i've never even conceived Blender without a scene before, and although i guess 
> there are cases where some background job may in principle be done without a 
> scene .. like image format conversions with the sequencer perhaps? (altho 
> even then i think the sta/end frame settings, and even the image format 
> settings, resolutions etc are part of scene data .. well i guess there is 
> some other example), i guess it does not hurt to have (an empty) scene around 
> in those cases.
>
>   
>> also suggest, if it gets accepted, that you print a msg to the console,
>> informing the user that a scene was created, something like: "No scene
>> available, creating an empty one.". Checking that the scene was actually
>>     
>
> +1
>
> ~Toni
>
>   
>> Campbell Barton wrote:
>>     
>>> Hey Willian,
>>>
>>> thaught of just adding checks, and while its okay for functions that
>>> directly use G.scene, there are functions that python calls that use
>>> G.scene
>>> Also, if you cover all cases, its adds up to a fair few checks.
>>>
>>> Just seems a simpler option to add a scene when importing Blender
>>> keep in mind this only effects blender when running in background mode.
>>>
>>> would be somthing like
>>> if (!G.scene)
>>>  add_scene("Scene");
>>>
>>> This would save us adding checks to World, Mesh, Scene? and others for
>>> this 1 rare case.
>>> It also seems logical that when you start blender and run a script in
>>> User mode you have a empty scene. so why not have 1 in background mode?
>>> - Cam
>>>       
>> --
>> Willian
>> _______________________________________________
>> Bf-python mailing list
>> Bf-python at projects.blender.org
>> http://projects.blender.org/mailman/listinfo/bf-python
>>     
> _______________________________________________
> Bf-python mailing list
> Bf-python at projects.blender.org
> http://projects.blender.org/mailman/listinfo/bf-python
>
>   


-- 
Campbell J Barton

133 Hope Street
Geelong West, Victoria 3218 Australia

URL:    http://www.metavr.com
e-mail: cbarton at metavr.com
phone: AU (03) 5229 0241



More information about the Bf-python mailing list