-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfcecodecScriptTemplate.py
More file actions
executable file
·78 lines (64 loc) · 2.58 KB
/
fcecodecScriptTemplate.py
File metadata and controls
executable file
·78 lines (64 loc) · 2.58 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# Copyright (C) 2021 and later Benjamin Futasz <https://github.com/bfut>
#
# This software is provided 'as-is', without any express or implied
# warranty. In no event will the authors be held liable for any damages
# arising from the use of this software.
#
# Permission is granted to anyone to use this software for any purpose,
# including commercial applications, and to alter it and redistribute it
# freely, subject to the following restrictions:
#
# 1. The origin of this software must not be misrepresented; you must not
# claim that you wrote the original software. If you use this software
# in a product, an acknowledgment in the product documentation would be
# appreciated but is not required.
# 2. Altered source versions must be plainly marked as such, and must not be
# misrepresented as being the original software.
# 3. This notice may not be removed or altered from any source distribution.
"""
fcecodecScriptTemplate.py - description
USAGE
python fcecodecScriptTemplate.py /path/to/model.fce [/path/to/output.fce]
REQUIRES
installing <https://github.com/bfut/fcecodec>
"""
import argparse
import pathlib
import sys
import fcecodec as fc
import numpy as np
from bfut_mywrappers import * # fcecodec/scripts/bfut_mywrappers.py
CONFIG = {
"fce_version" : "keep", # output format version; expects "keep" or "3"|"4"|"4M" for FCE3, FCE4, FCE4M, respectively
"center_parts" : False, # localize part vertice positions to part centroid, setting part position (expects 0|1)
}
script_path = pathlib.Path(__file__).parent
# Parse command-line
parser = argparse.ArgumentParser()
parser.add_argument("path", nargs="+", help="file path")
args = parser.parse_args()
# Handle paths: mandatory inpath, optional outpath
filepath_fce_input = pathlib.Path(args.path[0])
if len(args.path) < 2:
filepath_fce_output = filepath_fce_input.parent / (filepath_fce_input.stem + "_out" + filepath_fce_input.suffix)
else:
filepath_fce_output = pathlib.Path(args.path[1])
# custom functions go here
#
def main():
if CONFIG["fce_version"] == "keep":
fce_outversion = str(GetFceVersion(filepath_fce_input))
if fce_outversion == "5":
fce_outversion = "4M"
else:
fce_outversion = CONFIG["fce_version"]
mesh = fc.Mesh()
mesh = LoadFce(mesh, filepath_fce_input)
## do stuff here
## done doing stuff
WriteFce(fce_outversion, mesh, filepath_fce_output, CONFIG["center_parts"],
mesh_function=None)
PrintFceInfo(filepath_fce_output)
print(f"FILE = {filepath_fce_output}", flush=True)
if __name__ == "__main__":
main()