108 lines
5.3 KiB
Python
108 lines
5.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""
|
|
Created on Mon Apr 24 14:26:02 2023
|
|
|
|
@author: Edward Middleton-Smith
|
|
|
|
Braille 3D Model Product Creation
|
|
"""
|
|
|
|
# CLASSES
|
|
# ATTRIBUTE DECLARATION
|
|
# METHODS
|
|
# FUNCTION
|
|
# ARGUMENTS
|
|
# ARGUMENT VALIDATION
|
|
# ATTRIBUTE + VARIABLE INSTANTIATION
|
|
# METHODS
|
|
# RETURNS
|
|
|
|
# NORMAL METHODS
|
|
# FUNCTION
|
|
# ARGUMENTS
|
|
# ARGUMENT VALIDATION
|
|
# VARIABLE INSTANTIATION
|
|
# METHODS
|
|
# RETURNS
|
|
|
|
|
|
from translate_msg_2_braille import get_braille_translations, gen_product_inputs, input_product
|
|
from translate_braille_2_scad import gen_scrabble_sizes, elem_visibility, input_colour_themes, style
|
|
from export_3d import gen_product_permutations, gen_3d_models, gen_snippet_assembly
|
|
import argument_validation as av
|
|
|
|
# PARAMETERS
|
|
path_folder_cmd = 'C:\\"Program Files"\\OpenSCAD\\openscad' # 'C:\\"Program Files (x86)"\\OpenSCAD\\openscad' # local environment variable path for openscad commands
|
|
path_folder = "C:\\Users\\edwar\\OneDrive\\Documents\\Programming\\Python Scripts\\" # file export parent directory
|
|
my_option = -1 # index of product option - if not valid, user console input will be required
|
|
my_select = '' # character selection for Braille tile(s) (if chosen)
|
|
size_permutations = False # generate models for all size options?
|
|
size_option = -1 # size option as int index - not required if size_permutations
|
|
colour_permutations = False # generate models for all colour options?
|
|
colour_option = '' # colour option as str or int index - not required if colour_permutations
|
|
show_braille = elem_visibility.VISIBLE # how should Braille be shown?
|
|
show_let = elem_visibility.VISIBLE # EMBOSSED # how should plaintext be shown?
|
|
show_num = elem_visibility.HIDDEN # how should ordinality be shown?
|
|
# assembly component spacing
|
|
dx = 5 # horizontnal
|
|
dy = 10 # vertical
|
|
|
|
# METHODS
|
|
|
|
def generate(my_option = -1, my_select = '', size_permutations = False, size_option = -1, colour_permutations = False, colour_option = 'Purple', show_braille = elem_visibility.VISIBLE, show_let = elem_visibility.VISIBLE, show_num = elem_visibility.HIDDEN, dx = 5, dy = 10, path_folder_cmd = 'C:\\"Program Files"\\OpenSCAD\\openscad', path_folder = "C:\\Users\\edwar\\OneDrive\\Documents\\Programming\\Python Scripts\\"):
|
|
# FUNCTION
|
|
# generate Braille model(s)
|
|
# ARGUMENTS
|
|
# int my_option - index of product option - if not valid, user console input will be required
|
|
# str my_select - character selection for Braille tile(s) (if chosen)
|
|
# bool size_permutation -
|
|
# int size_option - index of product_sizes option - ignored if size_permutations
|
|
# # bool colour_permutation
|
|
# elem_visibility show_braille
|
|
# elem_visibility show_let
|
|
# elem_visibility show_num
|
|
# float dx
|
|
# float dy
|
|
# str path_folder_cmd
|
|
# str path_folder
|
|
# VARIABLE INSTANTIATION
|
|
_m ='generate'
|
|
# ARGUMENT VALIDATION
|
|
av.val_int(my_option, 'my_option', _m)
|
|
av.val_str(my_select, 'my_select', _m)
|
|
av.val_bool(size_permutations, 'size_permutations', _m)
|
|
av.val_int(size_option, 'size_option', _m)
|
|
av.val_bool(colour_permutations, 'colour_permutations', _m)
|
|
# av.val_type(show_braille, "<enum 'translate_braille_2_scad.elem_visibility'>", 'show_braille', _m)
|
|
# av.val_type(show_let, "<enum 'translate_braille_2_scad.elem_visibility'>", 'show_let', _m)
|
|
# av.val_type(show_num, "<enum 'translate_braille_2_scad.elem_visibility'>", 'show_num', _m)
|
|
av.val_type(show_braille, "<enum 'elem_visibility'>", 'show_braille', _m)
|
|
av.val_type(show_let, "<enum 'elem_visibility'>", 'show_let', _m)
|
|
av.val_type(show_num, "<enum 'elem_visibility'>", 'show_num', _m)
|
|
av.val_int(dx, 'dx', _m)
|
|
av.val_int(dy, 'dy', _m)
|
|
av.val_str(path_folder_cmd, 'path_folder_cmd', _m)
|
|
av.val_str(path_folder, 'path_folder', _m)
|
|
# METHODS
|
|
mystyle = style(show_braille, show_let, show_num)
|
|
# Get Braille dictionary + delimiters
|
|
braille_translations = get_braille_translations()
|
|
# Get list of products that can be generated
|
|
products = gen_product_inputs(braille_translations)
|
|
# input product selection from user and translate to braille
|
|
my_product = input_product(braille_translations, products, my_option, my_select) # my_option)
|
|
# get list of product size configurations
|
|
sizes_product = gen_scrabble_sizes()
|
|
# generate product size (and content for Scrabble tile array) permutations
|
|
mymsgs, myszs = gen_product_permutations(my_product, sizes_product, size_permutations, size_option)
|
|
# get product colour selection
|
|
colour_themes = input_colour_themes(colour_permutations, colour_option)
|
|
# generate openscad, stl, and png files of selected product(s)
|
|
gen_3d_models(braille_translations, my_product, mymsgs, myszs, my_product.line_length, path_folder, path_folder_cmd, mystyle, colour_themes)
|
|
# generate assembly of products for promotional content, as scad + png
|
|
gen_snippet_assembly(dx, dy, my_product.line_length, colour_themes, myszs, my_product, path_folder, path_folder_cmd, mystyle)
|
|
|
|
# generate()
|
|
# generate(1, 'A')
|
|
generate(my_option, my_select, size_permutations, size_option, colour_permutations, colour_option, show_braille, show_let, show_num, dx, dy, path_folder_cmd, path_folder)
|
|
# generate(my_option, my_select, size_permutations, size_option, colour_permutations, colour_option, elem_visibility.VISIBLE, elem_visibility.VISIBLE, elem_visibility.VISIBLE, dx, dy, path_folder_cmd, path_folder) |