I work on some system that generates objects in spatial configurations using Blender. I have a few samples of objects (.blend) file (e.g., cube, cylinder, sphere) and they work so fine on my system. I tried to create more objects like: bottle, cup, toy etc, and I follow tutorials on you tube but I always get errors when using them with python system. One of these common errors is:
AttributeError: ‘AreaLamp’ object has no attribute ‘vertices’
Despite the fact that I compare the new blender files attentively to those the work well in the system, I have same papramters in both but they always raise errors. Any idea about what is missing?
Hi, I am relatively new to blender development myself. But it seems like it has something to do with an AreaLamp in the scene or python code.
Maybe you are iterating over a list of objects and trying to access vertex information for each of them I guess? In that case you might want to add a conditional to include only mesh type objects.
This might be a direction you should start investigating towards. The .blend files you have attached seem fine to me though. Maybe someone more skilled can elaborate and find the exact problem.
@BLUEINVERSION Indeed, I iterate over objects and this error always appear when I try to calculate the centroid of each object separately including the blender file of the object I created. So, If I use the object (Cone) among the objects list I have, it raises the error, while when I keep with the other original objects I have (e.g., Sphere, Cylinder, Cube) the system runs fine.
I even tried to use the same blender file of one of the objects that runs without problem (i.e., Cube), and make “save as” —> new name (i.e., Cone), and then removes the “Cube” and only adds the new object “Cone” to make sure that I use the same environment, but even this raises error.
So I donnt know what should I do exactly and what is the difference between the Cone.blend and the Cube.blend? Do you have any concrete idea? what do you mean by (adding a conditional), any example?
From your description it really sounds mysterious. What I was talking about was, since you have that error there might be an area lamp somewhere. So try adding a conditional like this:
BEFORE (you are iterating over objects like this it seems right now)
for ob in bpy.context.scene.objects:
print(ob.name)
AFTER (with added conditional)
for ob in bpy.context.scene.objects:
if(ob.type == 'MESH'):
print(ob.name)
This way you can only let MESH type objects pass and avoid area lamps etc.
Hope you understand what I tried to explain. Let me know if this works.
Of course, the print line is an example. You will perhaps have a centroid calculation function there.