about summary refs log tree commit diff
path: root/src/python/experiments/view.py
diff options
context:
space:
mode:
authorhanemile <emile.hansmaennel@gmail.com>2018-03-19 20:47:13 +0100
committerhanemile <emile.hansmaennel@gmail.com>2018-03-19 20:47:13 +0100
commitd0f19b8bc7ab11449cea028106504cacecd94f66 (patch)
tree8ce0c9298694554a46545731c949fb18332669cb /src/python/experiments/view.py
parent996e5529f566d7c64763c47348fc68fae51ef6a4 (diff)
cleaned up
Diffstat (limited to 'src/python/experiments/view.py')
-rw-r--r--src/python/experiments/view.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/python/experiments/view.py b/src/python/experiments/view.py
new file mode 100644
index 0000000..a30ec48
--- /dev/null
+++ b/src/python/experiments/view.py
@@ -0,0 +1,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)