Skip to content

Instantly share code, notes, and snippets.

@zeffii
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeffii/bd8e2ad041df700b0bef to your computer and use it in GitHub Desktop.
Save zeffii/bd8e2ad041df700b0bef to your computer and use it in GitHub Desktop.
import bpy
''' selects an set which is the same as a direct previous set, removed them at the end '''
import mathutils
from mathutils import Vector
def check_similarity(old_set, new_set, distance=0.0001):
if None in old_set:
return False
else:
for co_old, co_new in zip(old_set, new_set):
if (co_old-co_new).length < distance:
continue
else:
return False
# reaches here only if all old/new coordinates where closer than 'distance'.
return True
bpy.ops.curve.select_all(action='DESELECT')
obj = bpy.context.active_object
splines = obj.data.splines
old_set = None, None, None
# A Curve data-type can hold multiple disjoint curves/splines
for idx, spline in enumerate(splines):
for cidx, bp in enumerate(spline.bezier_points):
new_set = (bp.co, bp.handle_left, bp.handle_right)
if check_similarity(old_set, new_set):
print(idx, cidx)
bp.select_control_point = True
else:
old_set = new_set
bpy.ops.curve.delete(type='VERT')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment