This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
This file contains hidden or 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 | |
custom_size = 5 | |
# add cube into the scene | |
bpy.ops.mesh.primitive_cube_add(size=custom_size) | |
cube_obj = bpy.context.active_object | |
# move the cube up half way on the Z axis | |
cube_obj.location.z = custom_size / 2 |
This file contains hidden or 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 JSON files | |
import json | |
# extend Python's functionality to work with file paths | |
import pathlib | |
# extend Python's functionality to print data in a readable way | |
import pprint | |
# give Python access to Blender's functionality |
This file contains hidden or 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 | |
verts = [ | |
(-1.0, -1.0, -1.0), | |
(-1.0, 1.0, -1.0), | |
(1.0, 1.0, -1.0), | |
(1.0, -1.0, -1.0), | |
(-1.0, -1.0, 1.0), | |
(-1.0, 1.0, 1.0), | |
(1.0, 1.0, 1.0), |