Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. import bpy
  2. context = bpy.context
  3. scene = context.scene
  4. curve_ob = context.object
  5. obs = [o for o in context.selected_objects if o is not curve_ob]
  6.  
  7. res = 10
  8. cyclic = False
  9. new_obs = []
  10. o = 0 if cyclic else 1
  11. pts = res - 1
  12. for i in range(pts + o):
  13. s = obs[i % len(obs)].copy()
  14. s.location = (0, 0, 0)
  15. fp = s.constraints.new(type='FOLLOW_PATH')
  16. fp.target = curve_ob
  17. fp.use_fixed_location = True
  18. sc = s.constraints[0]
  19. sc.offset_factor = i / pts
  20. scene.collection.objects.link(s)
  21. new_obs.append(s)
  22.  
  23. # remove constraints
  24. scene.update()
  25. for s in new_obs:
  26. sc = s.constraints[0]
  27. s.location = s.matrix_world.translation
  28. s.constraints.remove(sc)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement