Target Spot

Over on RCS somebody was asking for a 3dsmax style target spotlight. I had a few minutes to spare this morning and threw this together for them- thought I’d share it here in case others might find it useful. Just drop this script in your scripts/startup folder and you’ll have a new ‘Target Spot’ show up in the Add->Lights menu.

image

Script Download

4 Likes

You sir are a truly genius. No kidding.

Hi.

I noticed that your .py file doesn’t contain the usual GPL license paragraph.
As you may already know, Blender addons must be released under a GPL compatible license: https://www.blender.org/about/license/

Here is an example of GPL license paragraph that you could add at the top of your .py file:

# ----- BEGIN GPL LICENSE BLOCK -----
#
#  This program is free software; you can redistribute it and/or
#  modify it under the terms of the GNU General Public License
#  as published by the Free Software Foundation; either version 2
#  of the License, or (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software Foundation,
#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ----- END GPL LICENSE BLOCK -----

Thank you for this addon!

Doesn’t the spot lights in Blender already have a target mode?
You click on the yellow dot and touch an object and the light will snap it’s focus on said object.

Or is that just the area lights?

the yellow dot isn’t a ‘target mode’, it’s just a rotation gizmo. effectively, it is an inverted trackball rotation. you can click and drag the yellow dot to control the rotation of the spotlight, but it doesn’t snap to an object.

what I’ve done in this script isn’t anything too complex- it’s more of a ‘rig’ than anything else, but one of the benefits of having a spotlight set up this way is that you can move the light independently and it will always look at the target. meanwhile the target itself can be constrained to an object so the light tracks it as it moves. And then if you need to move the entire light while preserving its orientation, you can just transform the root.

I was positive the area lights have the Snapping feature, but I had to go back and check for the Spot lights and it looks like they do have the Snapping feature native in Blender.

How to use: Click on yellow dot, and drag to object. Spot light will snap to whatever object your mouse pointer touches.

Tim

and another way is to set a constraint: Add Damped track > select object > set -Z
this way it will always point to & follow objects origin aka be locked on a target :wink:

Cool, now make it do this

1 Like

yes, this script makes use of damped track constraints.

That’s pretty cool :slight_smile: ! I love it every time I find something that makes Blender’s tool box even better.

By the way I wasn’t dissing the add-on, just wasn’t sure if snapping for spots was native or not… we both weren’t sure.

Edit: Script downloaded…

For some reason I can’t get to show in the lights menu. I’ve added the script to the scripts startup folder. Any help

make sure it’s in the startup folder before blender starts (or restart blender if you need to). additionally, make sure it’s in the correct startup folder. many people have multiple versions of Blender, and each one has two different locations it could be in- in the installation directory, or the user folder for that version.

target
I’ve tried all of the above, still not appearing in the Add>> Lights drop down.

I’m using Blender 2.81 portable

Lets see if we can narrow it down to a script error or a load error- Try opening the script in Blender’s script editor and click “Run”, see if it appears there. If it shows up in the Add menu, the script isn’t being loaded because it’s not in the right location. If it doesn’t load, toggle the blender console (Window->toggle console) and see if there’s an error.

I just tried it with 2.81 portable and confirmed it works:

keep in mind that even ‘portable’ blender will write to your user folder, so check there:
%appdata%\Blender Foundation\Blender\2.81\scripts\startup\