# The most quick, clean and proper way to align a Sky Texture with a sun (Python)

For now I do something like this:

import bpy

objs = bpy.data.objects
for obj in objs:
if obj.type == 'LAMP':
if obj.data.type == 'SUN':
sun = obj
break

text = bpy.data.worlds['World'].node_tree.nodes['Sky Texture']
eul = sun.rotation_euler
text.sun_direction = (0,0,1)
text.sun_direction.rotate(eul)


It seems to work fine. But I have some doubts because of this weird effect near the horizon: