- I have a displacement modifier applied on the object.
- Image files were put into a sub-folder.
- I wanted to use script to search the sub-folder, replace the image(used by displacement modifier) and export it to stl each.
Currently i only got the exporting part working.
However I do not know how to get blender to:
a) search a folder, get the image files
b) replace it into current modifier
c) export and repeat a) until there's no file
Progress so far:
import bpy import os # get the current path and make a new folder for the exported meshes path = bpy.path.abspath('//stl/') if not os.path.exists(path): os.makedirs(path) # deselect all meshes bpy.ops.object.select_all(action='DESELECT') # select the object #object.select = True object = bpy.data.objects['pboard'] object.hide_select = False object.select = True bpy.context.scene.objects.active = object # export object with its name as file name fPath = str((path + object.name + '.stl')) #bpy.context.active_object = object bpy.ops.export_mesh.stl(filepath=fPath, use_selection=True) object.hide_select = True
P.S. the way how scripting blender to work with file and directories, is it the same as typical python? just so I know how to broaden my search when i walk into problems.