Hello to every one who is reading this,
I know how to convert and decimate files in Blender. Now I would like to safe me some time and get a litle in to the scripting.
So I checked here for some Questions/Answers, @wiki.blender.ord for documentations and scripts. Like here https://docs.blender.org/api/blender_python_api_2_76_1/bpy.ops.import_mesh.html
Also ich have copyed and changed this little Script:
import bpy import sys argv = sys.argv argv = argv[argv.index("--")+1:] stl_in = argv fbx_out = argv bpy.ops.import_mesh.stl(filepath=stl_in) bpy.ops.export_scene.obj(filepath=fbx_out)
As there is no import's for *.stp the exported fbx file by this script is garbage, if I convert a stl file with this.
Question 1: Is there a way to import *.stp File in to blender, with out converting the *.stp file in to *.stl or other by Blender acceptable type with external tools?
For the part of decimate of faces i found this script: https://gist.github.com/wooddar/0a5f409dc67cc045c421
I have tryed following:
bpy.ops.import_mesh.stl(filepath=stl_in) bpy.ops.object.modifier_add(type='DECIMATE') bpy.context.object.modifiers["Decimate"].ratio = number_of_faces_in_stl_obj/max_faces
Here I have two problems, the first it didn't worked at all. The second on is how can i get the number_of_faces_in_stl_obj so I can calculate the ratio.
Question 2: After I've imported an object with 'bpy.ops.import_mesh.stl(filepath=stl_in)' do I get with 'bpy.context.object' to some thing like number_of_surfaces/polygons?
In andvence thank you for you help.
EDIT: Added my Questions