Coverage for trimesh/__main__.py: 0%
26 statements
« prev ^ index » next coverage.py v7.14.1, created at 2026-06-24 04:40 +0000
« prev ^ index » next coverage.py v7.14.1, created at 2026-06-24 04:40 +0000
1import argparse
4def main():
5 """
6 A simple command line utility for accessing trimesh functions.
8 To display a mesh:
9 > trimesh hi.stl
11 To convert a mesh:
12 > trimesh hi.stl -e hey.glb
14 To print some information about a mesh:
15 > trimesh hi.stl --statistics
16 """
17 from .exchange.load import load
19 parser = argparse.ArgumentParser()
20 parser.add_argument("file_name", nargs="?")
22 parser.add_argument(
23 "-i",
24 "--interact",
25 action="store_true",
26 help="Get an interactive terminal with trimesh and loaded geometry",
27 )
28 parser.add_argument("-e", "--export", help="Export a loaded geometry to a new file.")
30 args = parser.parse_args()
32 if args.file_name is None:
33 parser.print_help()
34 return
35 else:
36 scene = load(args.file_name)
38 summary(scene)
40 if args.export is not None:
41 scene.export(args.export)
43 if args.interact:
44 return interactive(scene)
46 scene.show()
49def summary(geom):
50 """ """
51 print(geom) # noqa: T201
54def interactive(scene):
55 """
56 Run an interactive session with a loaded scene and trimesh.
58 This uses the standard library `code.InteractiveConsole`
59 """
60 local = locals()
62 from code import InteractiveConsole
64 # filter out junk variables.
65 InteractiveConsole(locals={k: v for k, v in local.items() if k != "local"}).interact()
68if __name__ == "__main__":
69 main()