Blend_3D_collections/main/headless_util.py

75 wiersze
2.6 KiB
Python
Czysty Zwykły widok Historia

2022-08-24 15:49:09 +00:00
# adding CLI arguments
# Used this as a basis:
# https://developer.blender.org/diffusion/B/browse/master/release/scripts/templates_py/background_job.py
2022-04-12 05:39:58 +00:00
import sys
2022-04-17 21:01:10 +00:00
import argparse
2022-04-12 05:39:58 +00:00
def get_python_args():
2022-04-12 05:39:58 +00:00
argv = sys.argv
if "--" not in argv:
argv = [] # as if no args are passed
else:
argv = argv[argv.index("--") + 1:] # get all args after "--"
usage_text = (
"Run Blend_My_NFTs heedlessly from the command line\n"
2022-04-12 05:39:58 +00:00
"usage:\n"
"blender -background --python <Path to BMNFTs __init__.py> -- --config-file <path to config file>"
)
parser = argparse.ArgumentParser(description=usage_text)
2022-04-12 17:09:34 +00:00
parser.add_argument("--config-file",
dest="config_path",
metavar='FILE',
required=True,
help="Provide the full file path of the config.cfg file generated from the addon"
)
2022-04-12 08:00:47 +00:00
parser.add_argument("--operation",
2022-04-12 05:39:58 +00:00
dest="operation",
choices=['create-dna', 'generate-nfts', 'refactor-batches'],
required=True,
help="Choose which operation you want to perform"
)
2022-04-12 08:00:47 +00:00
parser.add_argument("--save-path",
2022-04-12 05:44:21 +00:00
dest="save_path",
metavar='FOLDER',
required=False,
help="Overwrite the save path in the config file"
)
2022-04-15 15:36:55 +00:00
parser.add_argument("--batch-number",
2022-04-12 08:07:13 +00:00
dest="batch_number",
2022-04-15 15:36:55 +00:00
type=int,
2022-04-12 08:07:13 +00:00
required=False,
help="Overwrite the batch number in the config file"
)
2022-04-15 15:36:55 +00:00
parser.add_argument("--batch-data",
dest="batch_data_path",
metavar='FOLDER',
required=False,
help="Use pre-existing batch data for rendering"
)
2022-07-01 04:03:39 +00:00
parser.add_argument("--logic-file",
dest="logic_file",
metavar='FILE',
required=False,
help="Overwrite the logic file path in the config file"
)
2022-04-15 15:36:55 +00:00
parser.add_argument("--resume-failed-batch",
dest="resume_failed_batch",
action="store_true",
required=False,
help="Resume failed batch"
)
return parser.parse_args(argv), parser