-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
executable file
·43 lines (31 loc) · 990 Bytes
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import bpy
import bmesh
import sys
bpy.ops.object.delete(use_global=False)
mesh = bmesh.new()
inputFile = open(sys.argv[sys.argv.index("--") + 1])
verticesCount = int(inputFile.readline())
vertices = []
edges = []
for i in range(verticesCount):
coord = tuple(map(float,inputFile.readline().split()))
vertices.append(mesh.verts.new(coord))
edgeCount = int(inputFile.readline())
for i in range(edgeCount):
(u,v) = tuple(map(int,inputFile.readline().split()))
if (vertices[u],vertices[v]) not in mesh.edges:
if u>=len(vertices) or v>=len(vertices):
print(u,v)
mesh.edges.new((vertices[u],vertices[v]))
# edges.append((vertices[u],vertices[v]))
me = bpy.data.meshes.new("Mesh")
mesh.to_mesh(me)
mesh.free()
scene = bpy.context.scene
obj = bpy.data.objects.new("Object", me)
scene.objects.link(obj)
bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY')
bpy.ops.object.location_clear(clear_delta = False)
# Select and make active
scene.objects.active = obj
obj.select = True