Page 1 of 1

Layer bug

Posted: Thu Dec 28, 2006 4:21 am
by klopes
Hi, I'm Klópes, a blender user from Spain, and I carry a bug and a solution :wink: I hope it helps.
There's a problem at layer section:
the export script compares if the object layer is among the visible ones; it's not correct, from an object may be in several layers, then the resulting number is the sum. If this is the case, the object isn't exported as visible.
I've modified the code, it looks work now (comment lines are original). Please, verify it. Look for this section:

Code: Select all

	#get all the objects in this scene
#	activelayers = Window.ViewLayer()
#	for i in range(len(activelayers)):
#		activelayers[i] = 2**(activelayers[i]-1)
	object_list1 = Blender.Scene.GetCurrent().getChildren()
	object_list = []
	matnames= []
	activelayers = sum(map(lambda x:2**(x-1), Window.ViewLayer()))
	for obj in object_list1:
		if obj.Layer & activelayers:
#		if obj.Layer in activelayers:
			object_list.append(obj)
			collectObjectMaterials(obj)

layer detection bug

Posted: Sun Dec 31, 2006 2:39 am
by soxofaan
I use a more pythonic way (without the sum-map-lambda-logic_and stuff):

Code: Select all

	#get all the objects in this scene
	activelayers = Window.ViewLayer()
	object_list = []
	matnames = []
	for obj in Blender.Scene.GetCurrent().getChildren():
		for layer in obj.layers:
			if layer in activelayers:
				object_list.append(obj)
				collectObjectMaterials(obj)

Posted: Fri Jan 12, 2007 3:14 am
by klopes
That's just the bug, soxofaan! If you ask for activelayers, you get a list of them. But if an object is in MORE THAN ONE layer, its "layer" is the sum of the layer numbers, so it is no more in that list!

Please, any moderator could move this thread to "blender" forum?
:roll:

Posted: Fri Jan 12, 2007 11:04 pm
by soxofaan
klopes wrote:That's just the bug, soxofaan! If you ask for activelayers, you get a list of them. But if an object is in MORE THAN ONE layer, its "layer" is the sum of the layer numbers, so it is no more in that list!

Please, any moderator could move this thread to "blender" forum?
:roll:
hola klopes,

I'm aware of that. But the devil is in the details:
(see http://www.blender3d.org/documentation/ ... tml#Layers)
* obj.Layers (uppercase L) are the layers coded as a C-style bitmask, this is the thing you use
* obj.layers (lowercase l) is a python list of integers, referring to the layers the object is in, this is the thing I use

another indication the python API of blender needs some cleanup.... :wink:

regards

Posted: Mon Jan 15, 2007 7:57 pm
by klopes
:shock: oops. Ok, lets leave it for the moment... :?