conversion.py
Go to the documentation of this file.
1 # Copyright 2019 Shadow Robot Company Ltd.
2 #
3 # This program is free software: you can redistribute it and/or modify it
4 # under the terms of the GNU General Public License as published by the Free
5 # Software Foundation version 2 of the License.
6 #
7 # This program is distributed in the hope that it will be useful, but WITHOUT
8 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
10 # more details.
11 #
12 # You should have received a copy of the GNU General Public License along
13 # with this program. If not, see <http://www.gnu.org/licenses/>.
14 
15 # This is a python script, written for blender for batch conversion of dexterous hand collada (.dae) mesh files to .stl
16 # format, for use in the Mujoco simulator.
17 
18 import bpy
19 import os
20 
21 sr_description_path = '/home/user/projects/shadow_robot/base_deps/src/sr_common/sr_description'
22 
23 file_names = ['forearm', 'forearm_muscle', 'forearm_muscle_disk', 'forearm_lite', 'wrist', 'palm', 'knuckle',
24  'lfmetacarpal', 'F1', 'F2', 'F3', 'TH1_z', 'TH2_z', 'TH3_z']
25 
26 for file_name in file_names:
27  source_file_name = '{0}/hand/model/{1}.dae'.format(sr_description_path, file_name)
28  dest_file_name = '{0}/mujoco_models/meshes/arm_and_hand_meshes/{1}.stl'.format(sr_description_path, file_name)
29  print('Converting {0} to {1}...'.format(source_file_name, dest_file_name))
30 
31  bpy.ops.object.select_all(action='SELECT')
32  bpy.ops.object.delete()
33 
34  bpy.ops.wm.collada_import(filepath=source_file_name) # change this line
35 
36  bpy.ops.object.select_all(action='SELECT')
37 
38  bpy.ops.transform.rotate(value=4.71238898038, axis=(1.0, 0, 0))
39 
40  bpy.ops.export_mesh.stl(filepath=dest_file_name)


sr_description
Author(s): Ugo Cupcic
autogenerated on Tue Oct 13 2020 03:12:33