Skip to content

Instantly share code, notes, and snippets.

View Pullusb's full-sized avatar
🐍
pythoning

Samuel Bernou Pullusb

🐍
pythoning
View GitHub Profile
@Pullusb
Pullusb / auto_auto-smooth.py
Last active October 4, 2015 17:40
blenderSB assign autosmooth 30 degrees to objects
import bpy
from math import radians
# set smooth with auto-smooth active at 30 degrees
for o in bpy.context.selected_objects:
o.data.use_auto_smooth = True
o.data.auto_smooth_angle = radians(30)
for p in o.data.polygons:
p.use_smooth = True
@Pullusb
Pullusb / same_subdiv_as_view.py
Last active October 4, 2015 17:40
blenderSB subsurf number view to render
import bpy
# for all selected object if subsurf modifier:
# render subdivision number = view subdivision number
act = bpy.context.active_object
exist = False
for mod in act.modifiers:
if mod.type == 'SUBSURF':
sub = act.modifiers['Subsurf'].levels
@Pullusb
Pullusb / batch_render_layers.py
Created October 4, 2015 17:25
blenderSB batch render layers
import bpy
from math import radians
# Render all specified layers in //layers/ folder with layer names
# (based on layers name with layers manager addon)
C = bpy.context
def render(lay, sup=[]):
lay = lay - 1
@Pullusb
Pullusb / marker_timeline_range_select.py
Created October 4, 2015 17:48
blenderSB select timeline range through marker
import bpy
# navigate in timeline with marker
# markers must be named "start_1" "end_1" then "start_2" ...
scn = bpy.context.scene
def RangePart(n):
n = str(n)
scn.frame_start = scn.timeline_markers['start_' + n].frame
@Pullusb
Pullusb / Mega_apply_linked_obj_01.py
Created October 4, 2015 20:15
blenderSB apply Scale of linked object
import bpy, os
# Dirty apply Scale
# Apply transform even if objects are linked (if they share the same dimensions)
apply_scale = True
apply_rot = False # Useless option, if True, all linked objects will get the same rotation
C = bpy.context
scn = C.scene
@Pullusb
Pullusb / CSV_to_Vcards.py
Created October 8, 2015 18:56
python utils convert CSV files to vcf cards
# -*- coding: utf-8 -*-
#python 3.x
import csv
import sys
#convert a "comma separated values" file to vcf contact cards
#USAGE:
#CSV_to_Vcards.py CSV_filename
@Pullusb
Pullusb / seqcheck.py
Created October 14, 2015 13:58
python utils file sequence checker
import os, re
#sequence checker, print gaps in a numberred img/files sequence in current working directory
l = [f for f in os.listdir(os.getcwd()) if not f.endswith('.py')]
miss = 0
gap = 0
i = 0
for f in l:
num = re.search('^(.*?)(\d+)(\D*)$', l[i])
@Pullusb
Pullusb / Remove_unused_images_from_blend.py
Created November 29, 2015 02:17
blenderSB delete images from blend if no user or force delete
#removes images with no users
import bpy
images = bpy.data.images
U = 0
NU = 0
print (10*'-')
print ("total image before", len(bpy.data.images))
@Pullusb
Pullusb / Mirror_object_name.py
Created April 12, 2016 10:04
Blender - mirror names for any object
import bpy
#in armature you have mirror names
#this do the similar but for other objects (outside armatures)
def mirrorname(o):
if o.name[-5:-4] == "L":
o.name = o.name[:-5] + "R"
elif o.name[-5:-4] == "R":
o.name = o.name[:-5] + "L"
@Pullusb
Pullusb / rename_increment.py
Created April 12, 2016 10:53
Blender - increment number in name (if any) while removing trailing blender incrementation
import bpy, re
#increment number in name (if any) while removing trailing blender incrementation
#ex: obj02.L.001 >> obj03.L
def checkNum(n):
'''check if number in string (without trailing number)'''
if len(n) > 4:
return any(char.isdigit() for char in n)
#return bool(re.search(r'\d', inputString)) #regex method
else: