Created
June 12, 2015 18:37
-
-
Save zeffii/38b80cc0a3014caf616b 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 | |
''' | |
this could will go along and record for every point the positions of the set of knot + handles, | |
and check against the previous set. If all match the previous set, the index is recorded and the | |
loop is broken, then in the segment us selected solo and segment removed. This operation can be | |
repeated automatically untill no seqential duplicates are found. | |
''' | |
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 | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment