[Bf-committers] Python & G.scene

Campbell Barton cbarton at metavr.com
Thu Mar 23 12:21:18 CET 2006


hey,

Your point about not being able to assume default data is fair.
the difference with G.scene is...
A python scripter can check for a camera and add it if there are none.
in short. Python supports having no camera, but it dosent support having 
no scene.
G.scene not existing makes a whole lot of python functions segfault. 
simply because they access G.scene directly.

since blender would just crash. its hard for a python coder to debug.

there are a few solutions.
we could just check that G.scene exists when the -P switch is accessed. 
if its NULL then print a warning telling the user to make a new scene in 
python.
At least they would be warned.

Adding exception checks in B/Python isnt ideal since there are lots of 
places where G.scene is expected. also Python calls that access 
C/blender func's so to be safe we'd need to add a lot of exception 
checking just for this corner case.

adding this to python API's Blender.c:820  M_Blender_Init  function, 
would solve the problem in a way that would make background mode work as 
expected and no extra messing around would be needed on the side of B/Py 
coders or python scripters.

if (!G.scene) {
        Scene *sce= add_scene("1");
        set_scene(sce);
}

- Cam

Ton Roosendaal wrote:
> Hi,
>
> And without lamp or camera nothing really renders. Not to mention 
> there's no output path set for an image, render settings are in 
> unknown default, and there must be more issues I don't know yet. Then 
> it is unknown what scale the 3ds object is, what view would suit best, 
> where to put a lamp efficiently, etc.
>
> In general I prefer to not think in 'it might be possible so lets add 
> it', but try to stick to a certain design with strict rules. The first 
> case will always end up in troubles, the latter we can at least freeze 
> down as a spec and make sure it works.
>
> All coding work I've done on Blender sofar really requires a .blend to 
> run. The background rendering does lack certain features (like default 
> tmp path, yafray path, etc, stuff stored in the .B.blend now) which we 
> should look into.
>
> -Ton-
>
> On 23 Mar, 2006, at 11:03, Alexander Ewering wrote:
>
>>
>> On Thu, 23 Mar 2006, Campbell Barton wrote:
>>
>>> Ello,
>>> An example of thy this is usefull.
>>>
>>> Somebody makes a Python script that takes a 3ds and renders it. 
>>> saving the render and quitting.
>>> some python scripts create there own data and dont require loading 
>>> an existing blend file.
>>
>> It wouldn't be too difficult just delivering an empty (or almost-empty)
>> .blend file with that python script, would it?
>>
>> | alexander ewering              instinctive mediaworks
>> | ae[@]instinctive[.]de   http://www[.]instinctive[.]de
>> _______________________________________________
>> Bf-committers mailing list
>> Bf-committers at projects.blender.org
>> http://projects.blender.org/mailman/listinfo/bf-committers
>>
>>
> -------------------------------------------------------------------------- 
>
> Ton Roosendaal  Blender Foundation ton at blender.org http://www.blender.org
>
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at projects.blender.org
> http://projects.blender.org/mailman/listinfo/bf-committers
>


-- 
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-committers mailing list