question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AttributeError: 'Scene' object has no attribute 'area'

See original GitHub issue
File "C:\ProgramData\Anaconda3\lib\site-packages\trimesh\sample.py", line 152, in sample_surface_even
    radius = np.sqrt(mesh.area / (2 * count))
AttributeError: 'Scene' object has no attribute 'area'.

It occurs when calling sample_surface_even function. Already the lastest version. However, this bug doesn’t occur when running on Ubuntu 18.04.2.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

15reactions
mikedhcommented, Aug 16, 2020

Some formats are describing “scenes” (i.e. multiple meshes with transforms), if you want it to always be a “baked” Trimesh object in newer versions I would recommend using the force kwarg when loading:

mesh = trimesh.load('stuff.obj', force='mesh')

3reactions
jackdcommented, Jul 22, 2019

How did you generate your mesh? If you loaded it from an obj, the returned object is now either a mesh or scene. I’m unsure why this would be different under different versions of ubuntu, but if you’re creating the obj via some other means it may be being created differently.

If you’re only interested in the area, try the following:

def as_mesh(scene_or_mesh):
    if isinstance(scene_or_mesh, trimesh.Scene):
        mesh = trimesh.util.concatenate([
            trimesh.Trimesh(vertices=m.vertices, faces=m.faces)
            for m in scene_or_mesh.geometry.values()])
    else:
        mesh = scene_or_mesh
    return mesh

radius = np.sqrt(as_mesh(mesh).area / (2 * count))
Read more comments on GitHub >

github_iconTop Results From Across the Web

AttributeError while changing the display units using python ...
Error messages are pretty helpful in this case. "AttributeError: 'Scene' object has no attribute 'system'". Means that you can not access ...
Read more >
obj file loaded as Scene object instead of Trimesh object
the object class returned is Scene, which is incompatible with repair.fix_winding(mesh) , only Trimesh object are accepted. How can I force it ...
Read more >
trimesh 3.17.1 documentation
Trimesh is a pure Python (2.7- 3.3+) library for loading and using triangular meshes with an emphasis on watertight meshes. The goal of...
Read more >
internal error: modal gizmo-map handler has invalid area
internal error: modal gizmo-map handler has invalid area ... AttributeError: 'Scene' object has no attribute 'ats_settings'.
Read more >
Python Render Properties Tab 2.8 - Blender Artists
AttributeError : 'Scene' object has no attribute 'shading'. I took both code lines from the script listener of Blender, so I don't know...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found