Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. import bpy
  2.  
  3.  
  4.  
  5. object = bpy.context.object
  6. current_object_mode = bpy.context.active_object.mode
  7.  
  8. if object.type == 'ARMATURE':
  9.  
  10. armature = object.data
  11. print(" " + object.name + " is selected. \n \n")
  12.  
  13. inputted_keywords = input(" Keyword(s) to filter for resetting limit distance (case insensitive): ")
  14.  
  15.  
  16.  
  17. print("\n Scanning... \n")
  18.  
  19. keyword_array_items = inputted_keywords.split()
  20. number_of_keywords = len(keyword_array_items)
  21.  
  22. bone_names = []
  23. matched_bone_names = []
  24.  
  25.  
  26. for b in armature.bones:
  27. current_bone = b.name
  28. bone_names.append(current_bone)
  29.  
  30. if any(words in b.name.casefold() for words in keyword_array_items):
  31. print(current_bone)
  32. matched_bone_names.append(current_bone)
  33.  
  34. bpy.ops.object.mode_set(mode='POSE')
  35. pose_bone = object.pose.bones[current_bone]
  36.  
  37. has_constraint = getattr(pose_bone, "constraints")
  38.  
  39. temp = has_constraint[0].name
  40. print(temp)
  41.  
  42.  
  43. intersecting_bones = set.intersection(set(bone_names), set(matched_bone_names))
  44.  
  45. if intersecting_bones:
  46. print("\n Intersecting bones: ", format(intersecting_bones))
  47.  
  48. elif not intersecting_bones:
  49. print("\n Sorry, nothing found.")
  50.  
  51. bpy.ops.object.mode_set(mode = str(current_object_mode))
  52.  
  53. print ("\n Number of filter words used: " + str(number_of_keywords) + "\n")
  54.  
  55.  
  56. elif object.type != 'ARMATURE':
  57. print ("This object is not an armature.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement