1# Copyright (c) 2016-2019 Manfred Moitzi 2# License: MIT License 3import ezdxf 4 5# 8 corner vertices 6cube_vertices = [ 7 (0, 0, 0), 8 (1, 0, 0), 9 (1, 1, 0), 10 (0, 1, 0), 11 (0, 0, 1), 12 (1, 0, 1), 13 (1, 1, 1), 14 (0, 1, 1), 15] 16 17# 6 cube faces 18cube_faces = [ 19 [0, 3, 2, 1], 20 [4, 5, 6, 7], 21 [0, 1, 5, 4], 22 [1, 2, 6, 5], 23 [3, 7, 6, 2], 24 [0, 4, 7, 3], 25] 26 27polygon5_vertices = [ 28 (0, 0, 0), 29 (2, 0, 0), 30 (2, 2, 0), 31 (1, 3, 1), 32 (0, 2, 0), 33] 34 35polygon5_face = [ 36 [0, 1, 2, 3, 4] 37] 38 39doc = ezdxf.new('R2000') 40msp = doc.modelspace() 41mesh = msp.add_mesh() 42with mesh.edit_data() as mesh_data: 43 mesh_data.vertices = cube_vertices 44 mesh_data.faces = cube_faces 45 46mesh5 = msp.add_mesh() 47with mesh5.edit_data() as mesh_data: 48 mesh_data.vertices = polygon5_vertices 49 mesh_data.faces = polygon5_face 50 51doc.saveas("cube_mesh_1.dxf") 52