Skip to content

Instantly share code, notes, and snippets.

View catprisbrey's full-sized avatar

Cat catprisbrey

View GitHub Profile
@catprisbrey
catprisbrey / blender_export_objects_to_gltf
Last active February 27, 2025 16:06
Blender - Export each object to GLTF
import bpy
import os
## resets transforms to 0, applies modifiers, exports them all based on file name and skips any with the suffix "-noimp"
# Get the blend file name (without extension) and its directory, all lowercase
blend_path = bpy.data.filepath
blend_name = os.path.splitext(os.path.basename(blend_path))[0].lower()
export_folder = os.path.join(os.path.dirname(blend_path), blend_name)
@catprisbrey
catprisbrey / ffmpeg_covert_n_scale.txt
Created January 16, 2025 15:06
FFMPEG convert and scale videos or GIFs to MP4
## Simple script i use to convert larger files or GIFs to smaller MP4s for using in BlueSky or Discord.
## Change the 'SOURCE' to whatever path to your file. And change 'EXPORT.mp4' to whatever you want the final file to be.
## The 'trunc(iw/2)' gives you control of scale. '/2' is half size, '/4' is quater size, etc.
ffmpeg -i SOURCE -movflags faststart -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" EXPORT.mp4
@catprisbrey
catprisbrey / blender_add_all_nla_tracks.txt
Created January 16, 2025 14:55
Blender to Godot - Add all NLA Tracks and strips
import bpy
## Sometimes you add a LOT of NLA aniamtions to your blend file and want to add them to your model fast.
## OR you hate your animations being out of order, just remove them and re-add them for some quick
## alphabatising.
# Get the current object with an animation
obj = bpy.context.object
# Ensure the object has animation data
@catprisbrey
catprisbrey / blender_rename_nla_strips_to_track_names.txt
Last active January 16, 2025 14:57
Blender to Godot - Rename NLA strips to match track names
import bpy
## NLA editor is annoying, that strips and tracks have different names, and in Godot sometimes i see
## my strip names and not track names. Who knows why. This will rename all strips to match their track names.
# Get the current scene
scene = bpy.context.scene
# Iterate through all objects in the scene
for obj in scene.objects:
@catprisbrey
catprisbrey / blender_rename_mesh_match_object
Last active January 16, 2025 14:58
Blender to Godot - Rename Meshs to match their Object name
import bpy
## I can't remember why i wanted this, but i wanted the meshes to match their object names.
## In case that's useful for anybody else, here it is.
# Iterate through all objects in the scene
for obj in bpy.context.scene.objects:
# Check if the object is a mesh and its name ends with "-col"
if obj.type == 'MESH' and obj.name.endswith('-col'):
# Remove the "-col" suffix from the object name
@catprisbrey
catprisbrey / blender_add_-col_to_objects
Last active February 24, 2025 04:41
Blender to Godot - Add "-col" to every object name. Useful for simple collision shape generation
import bpy
for obj in bpy.data.objects:
obj.name += "-col"