[Script] - Connect Sun with Cycles Sky Texture.

If anyone’s interested, I’ve made a little UI for this script - since I use it quite a lot :slight_smile:
Download addon: https://www.dropbox.com/s/wap2jimkud5dntv/link_sky_with_sun.py


Hi Gregzaal,

Thanks a lot! Looks nice but I get this error when installing the new script. Am I the only one?


Regards,

You seem to have an addon named “random.py” installed. This is a really bad name and conflicts with the built-in module used for random number generation. If you delete or rename that file, maybe restart blender, it should work.

C:\Users\Carlos\AppData\Roaming\Blender Foundation\Blender\2.70\scripts\addons\random.py is the one I’m talking about

Thanks Greg!

Thanks a lot Greg for taking some time to answer me.
I cleaned all the previous scripts and even done a complete re-install of Blender, but for some reason the script doesn’t appears in the addons list after installing it (it appears in it’s folder C:\Users\Carlos\AppData\Roaming\Blender Foundation\Blender\2.70\scripts, thou)

Must be doing something wrong as it looks I’m the only one having this problem :S

Thanks again anyway!

saw your post on BlenderNation and just following up. excellent script good sir!

Found my mistake.

Instead of going to Greg’s Dropbox page, I was downloading the script directly clicking right button and then “Save As”. Even if I was getting the python script (link_sky_with_sun.py) the code was corrupted with html lines.
Downloaded and installed correctly in Blender now.

Sadly the script still doesn’t works for me… Once I create the Sky Texture, a Sun and link them with the script, moving the sun around doesn’t updates the sky at all :S

Cheers,

Did you click the Link Sky To Sun button? At first I didn’t realize that I had to do that. Then it worked.

This is already a really useful script. I think it would be a bit more practical if it was also possible to rotate the sun using a slider on the World panel instead of rotating the sun in the 3d view, but even the way it works right now is very good.

EDIT:

There is more to it. The way I get the script to work is that after I click the Link button I have to save and close the file. Then reopen it and then I can see the Reload Trusted button (next to the drop-down list of render engines). I need to click the button every time I reopen the file.

The “Reload Trusted” thing is annoying, but it applies to all drivers and scripts in a blend. What I do is enable “Auto
Run Python Scripts” (which includes drivers) in the user preferences, and then excluded my Downloads folder just in case :slight_smile:


That was exactly it! :slight_smile:
The script now works flawless for me.

Thanks Greg, Swirlypillow and Arcadi for your help.

Sweet and Awesome!

Thanks Greg and Oscurart for being awesome humans! Just what I needed :smiley:

Thank you very much for this. It works a treat ( im using 2.71 at the moment)

this really should just be added to Blender as a toggle in the world panel, or as an add-on. i use it all the time - it rocks. :slight_smile:

Thanks! Really useful.

Thank you both Greg and Eugenio Pignataro for this absolutely needed add-on which I use from the time you made it available, and I can’t do without it in Cycles. As someone already stated it should be included by default in Blender but it’s not, and I’m surprised it’s not even included in the Addons Contrib or External (sic!). It’s the simplest and most elegant way to link the Sky Texture to a Sun lamp.

Hello guys and gals, due to the changes coming in version 2.79 relative to class registration (https://wiki.blender.org/index.php/Dev:2.8/Source/Python/UpdatingScripts#Class_Registration) and because the script link_sky_to_sun.py wasn’t working with the latest 2.79 64bit development build (Hash: 718af8e), I found the issue and corrected it:

raw 126
changed from
bpy.types.CyclesWorld_PT_surface.append(sun_sky_menu_func)
to
bpy.types.CYCLES_WORLD_PT_surface.append(sun_sky_menu_func)

raw 134
changed from
bpy.types.CyclesWorld_PT_surface.remove(sun_sky_menu_func)
to
bpy.types.CYCLES_WORLD_PT_surface.remove(sun_sky_menu_func)

Now it works again and I hope this might help others using this great add-on.

The py API changes are only in current master and 2.8, 2.79 will still use the old API and won’t be affected.

Yes, thank you Greg. :slight_smile:

Hi,
Huge thanks for the script !
I know this thread is old.
But I wonder that if anyone could run it on 2.8 ?
Cheers,