about summary refs log tree commit diff
path: root/src/view.py
blob: a30ec48a062807a3e88a8aba1c0512a934e70a0f (plain)
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
44
45
46
47
48
import bpy
from numpy import genfromtxt
import os
import sys

directory = "stars/"
# # print(directory)
#
files = [sys.argv[3]]

# print("### \n\n")
#
# for data_file in os.listdir(directory):
#     files.append(data_file)
#     print(data_file)
#
# print("### \n\n")

for data in files:
    path = str(directory) + str(data)
    print(path)

    verts = genfromtxt(path, delimiter=', ', skip_header=0)

    print(verts)

# verts = [(-1.0, 1.0, 0.0), (-1.0, -1.0, 0.0), (1.0, -1.0, 0.0), (1.0, 1.0, 0.0)]

    # create mesh and object
    mesh = bpy.data.meshes.new(data)
    object = bpy.data.objects.new(data,mesh)

    # set mesh location
    object.location = bpy.context.scene.cursor_location
    bpy.context.scene.objects.link(object)

    # create mesh from python data
    mesh.from_pydata(verts,[],[])
    mesh.update(calc_edges=True)

    bpy.ops.object.select_all(action='SELECT')

for area in bpy.context.screen.areas:
    if area.type == 'VIEW_3D':
        for region in area.regions:
            if region.type == 'WINDOW':
                override = {'area': area, 'region': region, 'edit_object': bpy.context.edit_object}
bpy.ops.view3d.view_all(override)