specific part of menu for laby when using artlog toolbox

This commit is contained in:
philippe lhardy
2016-06-28 21:25:47 +02:00
parent afeafc1ec8
commit 6cf3e7c5c2

89
specificdoit.sh Normal file
View File

@@ -0,0 +1,89 @@
#!/bin/bash
specific_run()
{
local action=$1
if [[ $action == "list_labs" ]]
then
list_labs ./lab
elif [[ $action == emacsdevenv ]]
then
make -f ${JAVA_MAKEFILE} $action
else
echo "[ERROR] unrecognized specific action $action" >&2
return
fi
}
# first argument mandatory : directory containing generated .lab and .stl files ( usualy ./lab )
list_labs()
{
local lab_dir=$1
if [[ -d $lab_dir ]]
then
modified=0
s=()
properties=()
values=()
{
pushd $lab_dir
for stl_lab in $(ls *lab*.stl)
do
if [[ $stl_lab =~ ^([^0-9]*[0-9]*x[0-9]*).stl ]]
then
property=${BASH_REMATCH[1]}
value=$stl_lab
s+=("$property" "$value")
properties+=("$property")
values+=("$value")
fi
done
s+=(exit "Exit")
popd
}
while true
do
property=$($DIALOG --menu "Show stl file from $lab_dir" 20 100 10 ${s[@]} 3>&1 1>&2 2>&3)
if [[ $? = 0 ]]
then
if [[ -n $property ]]
then
if [[ $property == exit ]]
then
return 1
elif [[ $property == save ]]
then
echo "TODO"
return 0
fi
prop_len=${#properties[*]}
for (( i=0; i<${prop_len}; i++ ));
do
if [[ ${properties[$i]} == $property ]]
then
blender --python blender_import.py -- $lab_dir/${values[$i]}
fi
done
fi
else
return 2
fi
done
else
echo "[ERROR] lab dir '$propertyfile' not found" >&2
fi
}
# specific to laby project
if [[ ! -d lab ]]
then
echo "[INFO] Creating directory lab to save default lab created"
mkdir lab
fi
specific_menus+=(list_labs "Show_Labyrinth_with_blender")