38 lines
1.4 KiB
Python
38 lines
1.4 KiB
Python
import os
|
|
import sys
|
|
import ast
|
|
import random
|
|
import json
|
|
import product_gen.generate_product
|
|
from shapes.shape_description import _styles
|
|
|
|
from argparse import ArgumentParser
|
|
|
|
if __name__ == "__main__":
|
|
|
|
argv = sys.argv
|
|
argv = argv[argv.index("--") + 1:]
|
|
shape_params = json.loads(argv[0])
|
|
shape = shape_params['shape']
|
|
output = shape_params['output']
|
|
|
|
if not os.path.exists(os.getcwd() + "/" + output):
|
|
os.makedirs(os.getcwd() + "/" + output)
|
|
|
|
shape_parameters = {}
|
|
shape_parameters["shape"] = shape
|
|
shape_parameters["output"] = output
|
|
shape_parameters["height"] = float(shape_params["height"])
|
|
shape_parameters["radius"] = float(shape_params["radius"])
|
|
shape_parameters["fixture_radius"] = float(shape_params["fixture_radius"])
|
|
shape_parameters["fixture_length"] = float(shape_params["fixture_length"])
|
|
shape_parameters["stem_length"] = float(shape_params["stem_length"])
|
|
shape_parameters["style"] = random.choice(list(_styles.keys()))
|
|
shape_parameters["division_pattern"] = shape_params["division_pattern"]
|
|
shape_parameters["division_param1"] = float(shape_params["division_param1"])
|
|
shape_parameters["division_param2"] = float(shape_params["division_param2"])
|
|
|
|
product_gen.generate_product.generate(shape_parameters, output)
|
|
|
|
with open(os.getcwd() + "/" + output + "/"+ output + '.json', 'w') as outfile:
|
|
json.dump(shape_parameters, outfile)
|