From f59690ea324d919dd18fe69e8e48de88f292b2d0 Mon Sep 17 00:00:00 2001 From: TigerKat Date: Tue, 23 Jul 2019 11:37:25 +0930 Subject: [PATCH] Added 'geo_list.py' a tool for listing models in a .geo . --- README.md | 9 +++++++++ geo_list.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 geo_list.py diff --git a/README.md b/README.md index a9c662b..7e8e50a 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,15 @@ Operation | Description rescale_all <scale> | Rescale all vertices in all models by multiplying them all by <scale> . Multiple operations can be specified and performed in the same run. +## geo_list.py + +A command line tool for list the model name inside of 1 or more .geo files. + +geo_list.py <file.geo> [<file.geo> ...] + +The output format is: +<geo_name> : <model_name> + ## Known Issues - Not all structures are handled (reflection quads) - Not all structures are regenerated when writing a .geo file. (Reductions) diff --git a/geo_list.py b/geo_list.py new file mode 100644 index 0000000..c895f71 --- /dev/null +++ b/geo_list.py @@ -0,0 +1,28 @@ +#! /usr/bin/python3 + +import sys +import re +from geo import Geo + +def listGeo(fn, fh): + geo = Geo() + geo.loadFromFile(fh) + for m in geo.models: + print("%s : %s" % (geo.header_modelheader_name.decode("utf-8"), m.name.decode("utf-8"))) + + + +if len(sys.argv) <= 1: + print("Usage:") + print(" %s " % (sys.argv[0], )) + exit() + + +for i in range(1, len(sys.argv)): + try: + fn = sys.argv[i] + fh = open(fn, "rb") + except: + print("Couldn't open '%s'." % (sys.argv[i], )) + continue + listGeo(fn, fh)