summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Seibert <stan@mtrr.org>2011-10-08 16:22:45 -0400
committerStan Seibert <stan@mtrr.org>2011-10-08 16:22:45 -0400
commitd1dd3e5a2b9567c6acb3ee19a88457110a6f4a3f (patch)
treee3aaa1d30823547a1336479da7033180c1e31965
parent1788d1284a4750924503f67b9e70142343c7fe5a (diff)
downloadchroma-d1dd3e5a2b9567c6acb3ee19a88457110a6f4a3f.tar.gz
chroma-d1dd3e5a2b9567c6acb3ee19a88457110a6f4a3f.tar.bz2
chroma-d1dd3e5a2b9567c6acb3ee19a88457110a6f4a3f.zip
Add a helper module to the chroma.models directory that takes
inventory of all the .stl/.stl.bz2 files present and creates building functions for each of them in the models module. This allows usage like the following: chroma-cam chroma.models.lionsolid chroma-cam chroma.models.tie_interceptor6 You don't need to worry about where the chroma package was actually installed. Loading from STL files listed on the command line still works, of course.
-rw-r--r--chroma/models/__init__.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/chroma/models/__init__.py b/chroma/models/__init__.py
new file mode 100644
index 0000000..4b19f94
--- /dev/null
+++ b/chroma/models/__init__.py
@@ -0,0 +1,20 @@
+import os.path
+import glob
+import sys
+
+from chroma.stl import mesh_from_stl
+
+class Loader(object):
+ def __init__(self, filename):
+ self.filename = filename
+ def __call__(self):
+ return mesh_from_stl(self.filename)
+
+# Create functions to load
+this_module = sys.modules[__name__]
+for filename in glob.glob(os.path.join(os.path.dirname(__file__),'*.stl*')):
+ name, ext = os.path.splitext(os.path.basename(filename))
+ while ext != '':
+ name, ext = os.path.splitext(name)
+ setattr(this_module, name, Loader(filename))
+