[Bf-python] Layer setting problem

Campbell Barton cbarton at metavr.com
Thu Nov 16 02:30:40 CET 2006


Martin Poirier wrote:
> --- Campbell Barton <cbarton at metavr.com> wrote:
>
>   
>> At the moment ob1.Layers = ob2.Layers can raise an
>> error if ob1 is in 
>> localView
>> the simple solution is to mask off the last 8 bits
>> when getting the 
>> layers, but this means a script running in Local
>> view cant creat a new 
>> oject in that local view.
>>
>> Would an acceptable solution be to allow local view
>> bits to be set by doing
>> ob.Layer =  layer & (G.vd->lay & 1<<21-1)
>>
>> The bad thing about this is that it assumes that the
>> object is in the 
>> current scene. it could be bad for objects in other
>> scenes however the 
>> worst thing is local bits will be set.
>>     
>
> I also think that is much too close to the bare metal,
> something which abstracts Blender's localview
> implementation would be much better. Something like:
>
> sce # Current scene
> ob  # Object you want to add to local view
> sce.AddToLocalView(ob)
>
> which would raise an error if the object is not
> already in the scene.
>
> Martin
>   
Unsure of the best solution still-
the basic premis is "I want an object in the same view as the current 
object" - for a script to run and make a new object  based on the 
existing object, in exactly the same layers, should not require special 
checks.

sce.AddToLocalView(ob) - may be ok, that also requires sce.isInLocalView(ob) - or some such command.

I think the scn.object stuff I did kindof works around this- scn.objects.new(obData) creates the object in layer G.vd->lay
- In many cases this is enough though there are still cases where youd want to move existing objects into the view.

Maybe its better not to even worry about the a spesific command to add an object to the local view

scn.objects.context.add(ob) - could add an object into the user context and therefor all view layers. - sofar Iv kept .add() .new() and .remove() to scn.objects but scn.objects.context is the same type as scn.objects with a flag so it only iterates on the context so this could be easerly added.

- Otherwise.  scn.setObjectViewContext(...) could be added too.

- Cam








More information about the Bf-python mailing list