Layer bug

Feature requests, bug reports and related discussion
Post Reply
5 posts • Page 1 of 1
klopes
Posts: 4
Joined: Thu Dec 28, 2006 4:13 am

Layer bug

Post by klopes » Thu Dec 28, 2006 4:21 am

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)

User avatar
soxofaan
Posts: 20
Joined: Sun Dec 31, 2006 2:32 am

layer detection bug

Post by soxofaan » Sun Dec 31, 2006 2:39 am

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)

klopes
Posts: 4
Joined: Thu Dec 28, 2006 4:13 am

Post by klopes » Fri Jan 12, 2007 3:14 am

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:

User avatar
soxofaan
Posts: 20
Joined: Sun Dec 31, 2006 2:32 am

Post by soxofaan » Fri Jan 12, 2007 11:04 pm

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

klopes
Posts: 4
Joined: Thu Dec 28, 2006 4:13 am

Post by klopes » Mon Jan 15, 2007 7:57 pm

:shock: oops. Ok, lets leave it for the moment... :?

Post Reply
5 posts • Page 1 of 1

Who is online

Users browsing this forum: No registered users and 0 guests