Accessing my own mesh class I'm scripting my own mesh class but don't manage to access to it.
import bpy
from math import sqrt
from mathutils import Vector
import bmesh

class Triangle(bpy.types.Mesh):
    bl_idname = &quot;Triangle&quot;

    def __init__(self, origin, depth=1):
        Mesh.__init__(name=&quot;Triangle.001&quot;)
        self.origin = origin
        self.depth = depth

        bm = bmesh.new()

        bm.verts.ensure_lookup_table()
        v1 = Vector((- sqrt(3)/2, -.5, 0))
        v2 = Vector((0, 1, 0))
        v3 = Vector((sqrt(3)/2, -.5, 0))

        bmv1 = bm.verts.new(v1)
        bmv2 = bm.verts.new(v2)
        bmv3 = bm.verts.new(v3)

        bm.edges.new([bmv1, bmv2])
        bm.edges.new([bmv2, bmv3])
        bm.edges.new([bmv3, bmv1])
        bm.faces.new([bmv1, bmv2, bmv3])

        bm.to_mesh(self)
        bm.free()

When I try to instanciate it, it is unknown:
&gt;&gt;&gt; steeve = Triangle()

Traceback (most recent call last):   File &quot;&lt;blender_console&gt;&quot;, line 1,
in  NameError: name 'Triangle' is not defined

Blender says, I'm not meant to register this class:

ValueError: register_class(...): expected a subclass of a registerable RNA type (Mesh does not support registration)

How can I access this class into console?
EDIT
My script is imported like this:
import bpy
import os

filename = os.path.join(&quot;C:\\yMAK\\triangle&quot;, &quot;triangle.py&quot;)
exec(compile(open(filename).read(), filename, 'exec'))
Alternatively
If we wish to make a special mesh class based on bpy.types.Mesh
import bpy


class Triangle(bpy.types.Mesh):
    def __init__(self, verts):
        self.is_triangle = True
        pass
    def __new__(cls, verts):
        me = bpy.data.meshes.new(&quot;Tri&quot;)
        # why bother with bmesh for a tri?
        me.from_pydata(verts, [], ((0, 1, 2),))
        return bpy.types.Mesh.__new__(Triangle, me)

# test
from math import sqrt
root = sqrt(3) / 2
context = bpy.context    
tri = Triangle(
   (
        (-root, -.5, 0),
        (0, 1, 0),
        (root, -.5, 0),
    )
)       


print(tri)
print(tri.is_triangle)
print(tri.vertices)
ob = bpy.data.objects.new(&quot;Tri&quot;, tri)
context.collection.objects.link(ob)

output
&lt;bpy_struct, Mesh(&quot;Tri.012&quot;) at 0x7fd4057b6c08&gt;
True
&lt;bpy_collection[0], MeshVertices&gt;

as well as triangle object linked to context collection.