diff options
Diffstat (limited to 'generat3d')
| -rw-r--r-- | generat3d/__main__.py | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/generat3d/__main__.py b/generat3d/__main__.py new file mode 100644 index 0000000..ae04742 --- /dev/null +++ b/generat3d/__main__.py @@ -0,0 +1,51 @@ +# generat3D - evaluate Daz DSON scenes and write .dbz files +# Copyright (C) 2026 Danilo M. <danix@danix.xyz> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +import argparse +import sys +from pathlib import Path + +from . import Error +from .config import library_roots +from .dbz import build, write +from .library import Library +from .scene import load + + +def main(argv=None): + ap = argparse.ArgumentParser( + prog="generat3d", + description="Evaluate a Daz scene and write the .dbz file for Diffeomorphic.") + ap.add_argument("scene", type=Path, help="the .duf scene") + ap.add_argument("-L", dest="roots", action="append", default=[], metavar="ROOT", + help="content library root, repeatable, searched in order; " + "replaces library_roots from the config file") + ap.add_argument("-o", dest="out", type=Path, metavar="OUT.dbz", + help="output file (default: the scene path with .dbz)") + args = ap.parse_args(argv) + try: + roots = library_roots(args.roots) + scene = load(args.scene, Library(roots)) + write(build(scene, roots), args.out or args.scene.with_suffix(".dbz")) + except Error as e: + print(f"generat3d: error: {e}", file=sys.stderr) + return 1 + return 0 + + +if __name__ == "__main__": + sys.exit(main()) |
