-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeouned
45 lines (34 loc) · 872 Bytes
/
geouned
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env python3
"""
Convert Cad geometry to CSG format for use in Monte Carlo Codes
"""
import argparse
import json
from pathlib import Path
import geouned
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument(
"-i",
"--input",
type=str,
default="config.json",
help="The path to the config JSON file",
)
parser.add_argument(
"-r",
"--reverse",
action="store_true",
help="Switch to Csg_to_CAD mode",
)
args = parser.parse_args()
def main():
if not Path(args.input).exists():
raise FileNotFoundError(f"config file {args.input} not found")
if args.reverse :
with open(args.input) as f:
config = json.load(f)
geouned.CsgToCad().export_cad(**config["export_cad"])
else:
geouned.CadToCsg.from_json(args.input)
if __name__ == "__main__":
main()