add animation gifs for new rack-mount systems, also update rbuild and the main readme to reflect these changes
This commit is contained in:
62
rbuild.py
62
rbuild.py
@ -20,11 +20,9 @@ class BuildSizeConfig:
|
||||
FILE_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
RACK_BUILD_DIR = os.path.join(FILE_DIR, 'rack/print')
|
||||
RACK_MOUNT_BUILD_DIR = os.path.join(FILE_DIR, 'rack-mount/print')
|
||||
BUILD_PARENT_DIR = os.path.join(FILE_DIR, 'stl')
|
||||
|
||||
RACK_MOUNT_DIR = os.path.join(FILE_DIR, 'rack-mount')
|
||||
RACK_BUILD_TARGET_SUB_DIR = 'rack'
|
||||
RACK_MOUNT_BUILD_TARGET_SUB_DIR = 'rack-mount'
|
||||
|
||||
ASSEMBLY_GIF_DIR = os.path.join(FILE_DIR, 'rack/assembly')
|
||||
ASSEMBLY_GIF_BUILD_DIR = os.path.join(FILE_DIR, 'assembly-guide/gifs')
|
||||
@ -49,6 +47,11 @@ ASSEMBLY_STEPS = [
|
||||
('attachXYPlates.scad', 16)
|
||||
]
|
||||
|
||||
MOUNT_ANIMATIONS = [
|
||||
('enclosed-box', 32),
|
||||
('tray', 32),
|
||||
('patch-panel', 32)
|
||||
]
|
||||
|
||||
def main():
|
||||
if not assertOpenscadExists():
|
||||
@ -97,9 +100,9 @@ def main():
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'--build_assembly_gifs',
|
||||
'--build_gifs',
|
||||
action='store_true',
|
||||
help='Generate the GIFS for the assembly guide.'
|
||||
help='Generate the GIFS for the assembly guide, as well as various rack-mount systems.'
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
@ -115,11 +118,12 @@ def run_build(args):
|
||||
build_gifs = args.build_assembly_gifs
|
||||
|
||||
if (build_var is not None) == (build_gifs is True):
|
||||
print("Please either provide the build (-b) variable, or the build-gifs option (--build-assembly-gifs)")
|
||||
print("Please either provide the build (-b) variable, or the build-gifs option (--build-gifs)")
|
||||
return
|
||||
|
||||
if build_gifs:
|
||||
build_assembly_gifs(config_var, dz, nightly)
|
||||
build_rack_mount_gifs(config_var, nightly)
|
||||
return
|
||||
|
||||
if target_var != "":
|
||||
@ -128,38 +132,25 @@ def run_build(args):
|
||||
final_target_directory_name = config_var
|
||||
|
||||
rackBuildDirFull = os.path.join(BUILD_PARENT_DIR, final_target_directory_name, RACK_BUILD_TARGET_SUB_DIR)
|
||||
#rackMountBuildDirFull = os.path.join(BUILD_PARENT_DIR, final_target_directory_name,
|
||||
# RACK_MOUNT_BUILD_TARGET_SUB_DIR)
|
||||
|
||||
if not os.path.exists(rackBuildDirFull):
|
||||
os.makedirs(rackBuildDirFull)
|
||||
|
||||
#if not os.path.exists(rackMountBuildDirFull):
|
||||
# os.makedirs(rackMountBuildDirFull)
|
||||
|
||||
if build_var == 'all':
|
||||
for dir_file in os.listdir(RACK_BUILD_DIR):
|
||||
build_single(RACK_BUILD_DIR, rackBuildDirFull, dir_file, config_var, dz, nightly)
|
||||
|
||||
#for dir_file in os.listdir(RACK_MOUNT_BUILD_DIR):
|
||||
# build_single(RACK_MOUNT_BUILD_DIR, rackMountBuildDirFull, dir_file, config_var, dz,
|
||||
# nightly)
|
||||
return
|
||||
|
||||
filename_rack = find_rack(build_var)
|
||||
#filename_rack_mount = find_rack_mount(build_var)
|
||||
|
||||
if not (filename_rack): #or filename_rack_mount):
|
||||
if not (filename_rack):
|
||||
print('File:', build_var, 'not found!')
|
||||
return
|
||||
|
||||
if filename_rack:
|
||||
build_single(RACK_BUILD_DIR, rackBuildDirFull, filename_rack, config_var, dz, nightly)
|
||||
|
||||
#if filename_rack_mount:
|
||||
# build_single(RACK_MOUNT_BUILD_DIR, rackMountBuildDirFull, filename_rack_mount, config_var, dz, nightly)
|
||||
|
||||
|
||||
def build_single(build_dir, target_dir, filename, config, dz, nightly):
|
||||
print('Building:', filename, 'from', build_dir, 'to', target_dir)
|
||||
openscad_args = construct_openscad_args(build_dir, target_dir, filename, config, dz)
|
||||
@ -169,18 +160,39 @@ def build_single(build_dir, target_dir, filename, config, dz, nightly):
|
||||
def build_assembly_gifs(config, dz, nightly):
|
||||
print('Building assembly-gifs. Source Dir:', ASSEMBLY_GIF_DIR, '| Target:', ASSEMBLY_GIF_BUILD_DIR)
|
||||
|
||||
if not os.path.exists(ASSEMBLY_GIF_TEMP_DIR):
|
||||
os.makedirs(ASSEMBLY_GIF_TEMP_DIR)
|
||||
|
||||
for (fileName, numSteps) in ASSEMBLY_STEPS:
|
||||
print('Building GIF for', fileName)
|
||||
openscad_args = construct_openscad_animation_args(
|
||||
ASSEMBLY_GIF_DIR, ASSEMBLY_GIF_TEMP_DIR, fileName, config, dz, numSteps
|
||||
)
|
||||
run_openscad(openscad_args, nightly)
|
||||
build_gif_from_png(fileName)
|
||||
build_gif_from_png(fileName, ASSEMBLY_GIF_TEMP_DIR, ASSEMBLY_GIF_BUILD_DIR)
|
||||
|
||||
def build_rack_mount_gifs(config, nightly):
|
||||
print('Building GIFs for rack-mounts systems')
|
||||
|
||||
for (system, numSteps) in MOUNT_ANIMATIONS:
|
||||
print('Building GIF for', system)
|
||||
system_dir = os.path.join(RACK_MOUNT_DIR, system)
|
||||
temp_dir = os.path.join(system_dir, 'tmp')
|
||||
|
||||
if not os.path.exists(temp_dir):
|
||||
os.makedirs(temp_dir)
|
||||
|
||||
openscad_args = construct_openscad_animation_args(system_dir, temp_dir, 'animate.scad', config, 10, numSteps)
|
||||
run_openscad(openscad_args, nightly)
|
||||
build_gif_from_png('animate', temp_dir, system_dir)
|
||||
|
||||
def build_gif_from_png(fileName, source, target):
|
||||
|
||||
if not os.path.exists(target):
|
||||
os.makedirs(target)
|
||||
|
||||
def build_gif_from_png(fileName):
|
||||
try:
|
||||
subprocess.run(["bash", BUILD_GIF_FROM_PNG_SCRIPT, fileName, ASSEMBLY_GIF_TEMP_DIR, ASSEMBLY_GIF_BUILD_DIR],
|
||||
subprocess.run(["bash", BUILD_GIF_FROM_PNG_SCRIPT, fileName, source, target],
|
||||
check=True)
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"Error calling shell script: {e}")
|
||||
@ -224,10 +236,6 @@ def find_rack(filename):
|
||||
return find_scad_file(RACK_BUILD_DIR, filename)
|
||||
|
||||
|
||||
#def find_rack_mount(filename):
|
||||
# return find_scad_file(RACK_MOUNT_BUILD_DIR, filename)
|
||||
|
||||
|
||||
def find_scad_file(directory, filename):
|
||||
for dir_file in os.listdir(directory):
|
||||
dir_file_normalized = dir_file.lower()
|
||||
|
||||
Reference in New Issue
Block a user