Last active
August 29, 2015 14:22
-
-
Save zeffii/bd8e2ad041df700b0bef to your computer and use it in GitHub Desktop.
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 | |
''' 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