Created
December 5, 2019 16:15
-
-
Save pawlos/3d6375b7cf6e5a77baabdaca88e7016e to your computer and use it in GitHub Desktop.
Imports data from the file into blender
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
from mathutils import Vector | |
import sys | |
file = open("c:\\temp\\FlareOn\\2019\\challenges\\demo\\output3.txt") | |
v = True | |
i = False | |
verts = [] | |
faces = [] | |
for l in file.read().splitlines(): | |
if "Vertex" in l: | |
continue | |
if "Indices" in l: | |
v = False | |
i = True | |
continue | |
a = l.split(",") | |
if v: | |
scale = 1.0000 | |
x=float(a[0]) | |
y=float(a[1]) | |
z=float(a[2]) | |
newVertex= (x*scale,y*scale,z*scale) | |
verts.append(newVertex) | |
if i: | |
faces.append((int(a[0]),int(a[1]),int(a[2]))) | |
#print(faces) | |
#print(verts) | |
mesh_data = bpy.data.meshes.new("cube_mesh_data") | |
mesh_data.from_pydata(verts, [], faces) | |
mesh_data.update() | |
obj = bpy.data.objects.new("My_Object", mesh_data) | |
scene = bpy.context.scene | |
scene.collection.objects.link(obj) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment