0
$\begingroup$

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 fine on my system. I tried to create more objects like: bottle, cup, toy, etc, and I follow tutorials on youtube but I always get errors when using them with python. One of these common errors is:

AttributeError: ‘AreaLamp’ object has no attribute ‘vertices’

This is particularly related to some code that loops over objects in the scene and use the vertices information of each object in order to calculate the centroid. So I can estimate that there is a problem in accessing vertex information.

Despite the fact that I compare the new blender files attentively to those that work well in the system, I have the same parameters in both but they always raise errors.

I attach a link to a new object (Cone) that I created which raised this error: Cone

VS

an original .blend file for an object (Sphere) which works in my python system without any problem: Sphere

So what is missing that makes the (Cone) object raises this error? Why isn't the vertex information accessible?

$\endgroup$
5
  • 1
    $\begingroup$ just from the error message looks like when looping through everything in the scene you get a lamp, which doesn't have vertices, so it breaks. do you know how that lamp gets there? $\endgroup$
    – wilks
    Oct 6 '20 at 10:25
  • $\begingroup$ @wilks: Actually not! I simply use the same code I used with the Sphere file (attached above) which works without problem. When I created the (Cone) I paid attention to remove any lamp and make parameters look similar to the Sphere.blend file , but despite that I got this error. I guess the problem is not in the code or else it wont have worked for the original blend files provided files by the developer (e.g., Sphere), the problem is related to something in the blend files that I should think of. I sent the blend files to some guys but no one got any idea about what is missing! Can you help? $\endgroup$
    – Amir Aly
    Oct 7 '20 at 7:34
  • 1
    $\begingroup$ you could add some print statements to the script to help debug it. here I can't do much without seeing the script $\endgroup$
    – wilks
    Oct 7 '20 at 8:50
  • $\begingroup$ The problem as noted above is undoubtedly related to the "other" objects in scene or selection not being of mesh type. Recent & related blender.stackexchange.com/questions/196713/… in that it checks the object type of objects in a scene mesh_objects_in_scene = [o for o in scene.objects if o.type == 'MESH'] If you are iterating over all objects in blend file bpy.data.objects then an object need not be linked to scene IMO Please add code to q rather than rely on others downloading blend files. Did you write the code? $\endgroup$
    – batFINGER
    Oct 7 '20 at 13:49
  • $\begingroup$ blender.stackexchange.com/questions/193966/… $\endgroup$
    – batFINGER
    Oct 7 '20 at 13:54
0
$\begingroup$

There's a chance you deleted the lamp but it's still lingering somewhere in your blendfile and the script is accessing it. To be sure this is not the case, try saving, closing, and opening the blendfile multiple times to completely get rid of unused data and try your script again. Or you can try copying the mesh files to a brand new blender scene without any object and run the script there

$\endgroup$
1
  • $\begingroup$ Opening and closing once is enough. For newer versions of Blender that wont work any more though, data has to be explicitly purged $\endgroup$ Feb 12 at 13:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.