add blender call with stl auto import.

Signed-off-by: philippe lhardy <philippe@pavilionartlogiciel>
This commit is contained in:
philippe lhardy
2015-02-21 21:51:48 +01:00
parent 0b33e56e0a
commit 4a8d555ad4
3 changed files with 79 additions and 2 deletions

6
README
View File

@@ -9,6 +9,10 @@ It was developped under debian 7/8 but since it is java based it might be very e
there is a console gui menu base with ./doit.sh there is a console gui menu base with ./doit.sh
requirement : you need a java jdk environment installed ( java + javac ) and ant
ex ubuntu : sudo apt-get install default-jdk ant
run it by : run it by :
________Linux distribution_____________________ ________Linux distribution_____________________
@@ -16,7 +20,7 @@ ________Linux distribution_____________________
mkdir github mkdir github
cd github cd github
git clone https://github.com/artlog/labystl.git git clone https://github.com/artlog/labystl.git
cd labystl.git cd labystl
./doit.sh ./doit.sh
ant ant
run run

8
blender_import.py Normal file
View File

@@ -0,0 +1,8 @@
import sys
import bpy
argv = sys.argv
argv = argv[argv.index("--") + 1:] # get all args after "--"
bpy.ops.import_mesh.stl(filepath=argv[0], filter_glob="*.stl", files="", directory="")

67
doit.sh
View File

@@ -128,6 +128,68 @@ edit_properties()
} }
# 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
}
possible_console_gui="whiptail dialog" possible_console_gui="whiptail dialog"
for DIALOG in $possible_console_gui for DIALOG in $possible_console_gui
@@ -151,7 +213,7 @@ action=initial
while [[ $action != quit ]] while [[ $action != quit ]]
do do
action=$($DIALOG --menu "Ultra Light IDE" 20 80 12 run "Run it" clean "Clean All" ant "Ant build" test "Test it" readme "Read me" code "Code" codebg "Code in background" deb "Debian package" properties "Edit Properties" create "Create a new class" quit "Quit" 3>&1 1>&2 2>&3) action=$($DIALOG --menu "Ultra Light IDE" 20 80 12 readme "Read me" clean "Clean All" ant "Ant build" run "Run it" list_labs "Show Labyrinth with blender" test "Test it" code "Code" codebg "Code in background" deb "Debian package" properties "Edit Properties" create "Create a new class" quit "Quit" 3>&1 1>&2 2>&3)
if [[ $action == run ]] if [[ $action == run ]]
then then
@@ -198,5 +260,8 @@ do
popd popd
fi fi
fi fi
elif [[ $action == list_labs ]]
then
list_labs ./lab
fi fi
done done