Advertisement
Jummit

Add UV Project modfier with projectors

Jun 13th, 2020
947
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.97 KB | None | 0 0
  1. import bpy
  2. from mathutils import Vector
  3.  
  4. directions = [
  5.     Vector((1.0, 0.0, 0.0)),
  6.     Vector((-1.0, 0.0, 0.0)),
  7.     Vector((0.0, 1.0, 0.0)),
  8.     Vector((0.0, -1.0, 0.0)),
  9.     Vector((0.0, 0.0, 1.0)),
  10.     Vector((0.0, 0.0, -1.0)),
  11. ]
  12.  
  13. def add_projectors():
  14.     bpy.ops.object.modifier_add(type='UV_PROJECT')
  15.     bpy.context.object.modifiers["UVProject"].projector_count = len(directions)
  16.     center = bpy.data.objects.new( "empty", None )
  17.     bpy.context.scene.collection.objects.link(center)
  18.     center.empty_display_type = 'CUBE'
  19.     for i in range(len(directions)):
  20.         axis = bpy.data.objects.new( "empty", None )
  21.         axis.empty_display_types = 'SINGLE_ARROW'
  22.         bpy.context.scene.collection.objects.link(axis)
  23.         axis.rotation_mode = 'QUATERNION'
  24.         axis.rotation_quaternion = directions[i].to_track_quat('Z','Y')
  25.         axis.parent = center
  26.         bpy.context.object.modifiers["UVProject"].projectors[i].object = axis
  27.  
  28. add_projectors()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement