Commit 8850d263 authored by Ivan Dages's avatar Ivan Dages
Browse files

fix converter : blender script moved

parent 1df3aa43
import sys, os, glob
import bpy
def printUsage():
print("Usage : ")
print("blender --background --python simplify.py file.STL input_dir output_dir")
print("[INFO] Blender executable : " + sys.argv[0])
print("[INFO] Working directory : " + os.getcwd())
print(" ")
# Clear scene
print("[INFO] Clearing scene...")
bpy.ops.object.select_all(action='SELECT')
bpy.ops.object.delete()
decimateRatio = 0.5
if len(sys.argv) >= 7:
decimateRatio = float(sys.argv[6])
if len(sys.argv) < 5:
print("[ERROR] No input directory provided")
printUsage()
exit(1)
elif len(sys.argv) < 6:
print("[ERROR] No output directory provided")
printUsage()
exit(1)
else:
inDirPath = sys.argv[4]
outDirPath = sys.argv[5]
stlFiles = glob.glob(os.path.join(inDirPath, "*.STL"))
i = 0
for file in stlFiles:
i = i + 1
print("[INFO] File " + str(i) + " / " + str(len(stlFiles)))
fileName = os.path.basename(file)
inFilePath = os.path.join(inDirPath, fileName)
outFilePath = os.path.join(outDirPath, fileName)
print("[INFO] STL file : " + fileName)
bpy.ops.import_mesh.stl(filepath=inFilePath, files=[{"name":fileName, "name":fileName}], directory=inDirPath)
bpy.ops.object.select_all(action='SELECT')
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.remove_doubles()
bpy.ops.mesh.normals_make_consistent()
bpy.ops.mesh.decimate(ratio=decimateRatio)
# Change of coordinate system
bpy.ops.object.mode_set(mode='OBJECT')
factor = 0.99 # z-fighting
bpy.ops.transform.resize(value=(factor, -factor, -factor))
bpy.ops.export_mesh.stl(filepath=outFilePath)
bpy.ops.object.delete()
print(" ")
print("[INFO] Work done, exiting Blender...")
exit()
#!/bin/bash
directory="$1"
# Remove last '/' if there is one
directory=${directory%/}
outDirectory="$2"
outDirectory=${outDirectory%/}
if [ -d "$outDirectory" ]
then
rm --verbose -rf "$outDirectory"
fi
mkdir --verbose -p "$outDirectory"
for xmlFile in "$directory"/*.xml
do
echo "$xmlFile"
cp --verbose "$xmlFile" "$outDirectory"
done
echo "SW export directory : $directory"
echo "Blender export directory : $outDirectory"
echo ""
/c/Program\ Files/Blender\ Foundation/Blender/blender.exe --background --python simplify.py "$directory" "$outDirectory"
#!/bin/bash
dir1="$1"
dir1=${dir1%/}
dir2="$2"
dir2=${dir2%/}
for filePath in "$dir1"/*.STL
do
file=${filePath##*/}
echo "$file :"
diff "$dir1"/"$file" "$dir2"/"$file"
done
\ No newline at end of file
......@@ -220,11 +220,13 @@ public class Component {
return false;
}
child.parent = null;
try {
((Group)this.sceneNode).getChildren().remove(child.getSceneNode());
((Group)this.sceneNode).getChildren().remove(child.getAxis().getVisualGroup());
} catch (Exception e) {
e.printStackTrace();
if (this.sceneNode != null) {
try {
((Group)this.sceneNode).getChildren().remove(child.getSceneNode());
((Group)this.sceneNode).getChildren().remove(child.getAxis().getVisualGroup());
} catch (Exception e) {
e.printStackTrace();
}
}
return this.children.remove(child);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment