![](https://i.imgur.com/mA3fyqb.png) import bpy, bmesh from math import * from mathutils import Vector import numpy as np def add_ramp(bm, z, ramp, angle): pc = ramp / z bm.edges.ensure_lookup_table() edge = bm.edges[5] edges = [bm.edges[i] for i in (8, 9, 10, 11)] bmesh.ops.subdivide_edges( bm, edges=edges, edge_percents={ e : (pc if e.verts[1].co.z > e.verts[0].co.z else 1 - pc) for e in edges}, use_grid_fill=True, cuts=1, ) bmesh.ops.translate(bm, verts=edge.verts, vec=(0, (z -ramp)* tan(angle), 0)) me = bpy.data.meshes.new("Shape") bm.to_mesh(me) ob = bpy.data.objects.new("Shape",me) bpy.context.collection.objects.link(ob) def draw(zTop, polygon): """this function receives 2 arguments : * zTop of type Integr: it's the maximum height * polygon of type list of tuple: it's coordinates of polygon * this function allows to draw a cube """ #coords = create_mesh(polygon) coords= polygon bm = bmesh.new() for v in coords: bm.verts.new(v) # print(bm.verts) #création de la base base = bm.faces.new(bm.verts) #processus d'extrusion hauteur = bmesh.ops.extrude_face_region(bm, geom=[base]) #ajout d'auteur d'extrusion bmesh.ops.translate(bm, vec=Vector((0,0,zTop)), verts=[v for v in hauteur["geom"] if isinstance(v,bmesh.types.BMVert)]) bm.normal_update() add_ramp(bm, zTop, 5, radians(45)) # coords = [(0,4, 0),(0,-4, 0), (4,-4, 0), (4,4, 0)] draw(10, coords)