Added convert.py

This commit is contained in:
Thomas FORGIONE
2016-11-22 15:23:53 +01:00
parent 14c27eb33b
commit 16e0e1ae00
5 changed files with 36 additions and 59 deletions
+20 -2
View File
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
from .obj import is_obj, OBJParser
from .ply import is_ply, PLYParser
from .obj import is_obj, OBJParser, OBJExporter
from .ply import is_ply, PLYParser, PLYExporter
def load_model(path):
parser = None
@@ -16,3 +16,21 @@ def load_model(path):
parser.parse_file(path)
return parser
def export_model(model, path):
exporter = None
if is_obj(path):
exporter = OBJExporter(model)
elif is_ply(path):
exporter = PLYExporter(model)
else:
raise Exception("File format not supported")
return exporter
def convert(input, output):
model = load_model(input)
exporter = export_model(model, output)
return str(exporter)