blenderfunc.utility¶
Commonly Used¶
- initialize()¶
Initialize Blender environments:
remove all data in the default scene
use absolute paths
- initialize_folder(directory, clear_files=False)¶
Make a folder if it does not exist
- Parameters
directory (str) – The path to the directory will be initialized
clear_files (bool, optional) – Remove all files and directories in the folders
- save_blend(filepath='/tmp/temp.blend')¶
Save “.blend” file to filepath, the output directory will be created
- setup_custom_packages(required_packages=None, reinstall_packages=False)¶
Setup custom python packages in the Blender’s python directory. This function will check if a package has been installed, if not, then use the pip tool embedded in Blender’s python environment to install the missing packages
- Parameters
required_packages (list of str) – The python packages to be installed
reinstall_packages (bool, optional) – Force reinstall packages if true
- get_object_by_name(name)¶
Get the blender object by its name
- get_material_by_name(name)¶
Get the blender material by its name
Others¶
- remove_all_data()¶
Remove all data except the default scene
- remove_all_images()¶
Remove all images
- remove_all_materials()¶
Remove all materials
- remove_all_meshes()¶
Remove all mesh objects
- remove_all_cameras()¶
Remove all camera objects
- remove_all_lights()¶
Remove all camera objects
- seconds_to_frames(seconds)¶
Convert seconds to frames
- frames_to_seconds(frames)¶
Convert frames to seconds
Environments¶
- get_blender_path()¶
Get root path to blender software
- get_blender_version()¶
Get the version of blender
- get_custom_python_packages_path()¶
Get the path to the custom python packages of Blender
- get_pre_python_packages_path()¶
Get the path to the previous python packages of Blender
- get_python_bin_folder()¶
Get the python bin folder of Blender
- get_python_bin()¶
Get the python binary path of Blender
- get_installed_packages()¶
Get the installed packages in previous and custom python packages path
- Returns
The installed python packages
- Return type
dict, key=package_name, val=package_version