This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# give Python access to Blender's functionality | |
import bpy | |
# add a cube into the scene | |
bpy.ops.mesh.primitive_cube_add() | |
# get a reference to the currently active object | |
cube = bpy.context.active_object | |
# insert keyframe at frame one | |
start_frame = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
import bmesh | |
bpy.ops.mesh.primitive_cube_add() | |
cube_obj = bpy.context.active_object | |
bpy.ops.object.editmode_toggle() | |
bpy.ops.mesh.select_all(action="DESELECT") | |
bm = bmesh.from_edit_mesh(cube_obj.data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
import pathlib | |
# check if we are running from the Text Editor | |
if bpy.context.space_data != None and bpy.context.space_data.type == "TEXT_EDITOR": | |
# get the path to the SAVED TO DISK script when running from blender | |
print("bpy.context.space_data script_path") | |
script_path = bpy.context.space_data.text.filepath | |
else: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pathlib | |
import pprint | |
path_to_current_dir = pathlib.Path(__file__).parent | |
########### | |
# Option 1 | |
########### | |
blend_files = list() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# extend Python's functionality to work with file paths | |
import pathlib | |
# give Python access to Blender's functionality | |
import bpy | |
def remove_libraries(): | |
"""remove the linked blend files""" | |
bpy.data.batch_remove(bpy.data.libraries) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# give Python access to Blender's functionality | |
import bpy | |
# extend Python's math functionality | |
import math | |
# extend Python functionality to generate random numbers | |
import random |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# give Python access to Blender's functionality | |
import bpy | |
# extend Python functionality to generate random numbers | |
import random | |
def partially_clean_the_scene(): | |
# select all object in the scene | |
bpy.ops.object.select_all(action="SELECT") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
last_frame = 90 | |
# set the lenght of the animation | |
bpy.context.scene.frame_end = last_frame | |
# add a Bezier circle curve into the scene | |
bpy.ops.curve.primitive_bezier_circle_add() | |
bezier_circle_obj = bpy.context.active_object |