Quickly setting the point at which the light sources in the scene should be directed

When we set up lighting in a scene in Blender, we usually set the direction of the light to the desired point manually for each light source. However, this process can be simplified and we can specify the point to which all selected light sources in the scene will be directed at once.

It’s very easy to do.

Select several light sources. Please note that one of them must be an active object in the scene. Now press Shift+ t on the keyboard and move the mouse.

When moving the mouse cursor, all selected light sources now “follow” the cursor with their directions. After clicking with the left mouse button, they will all remain directed to the click point.

This functionality is provided by executing the transform_axis_target() operator. We can also do this using the Blender Python API.

Since this operator is bound to the 3D viewport context, the operator call must be wrapped with temp_override().

First, we need to get pointers to the 3D viewport area and region.

Now we can use a temporary override of the context by passing the received values ​​in parameters,

and call the operator.

Please note that the value “INVOKE_REGION_WIN” must be passed in the operator parameters, otherwise the operator will fail with an error.

At the same time, we can get rid of the need to necessarily assign one of the selected light sources to the active object. Since we are already using temp_override(), we can override the active object inside it by passing a pointer to it in the parameters.

By calling it, we can specify the direction point for light sources with the mouse in the 3D viewport working area.

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comment
Newest
Oldest Most Voted
Inline Feedbacks
View all comments