# Align face with a vertex via python

Hi and good days to everyone.

What I have been trying to accomplish is rotating the plane (in the image below) in its x (red) direction until it aligns with the top vertex of the cone. Is there a way for me accomplish this via scripting? My tryouts have given me no result.

Edit: I have added a picture how it should look. And top of the cone is just a point. It could be 3d cursor.

• you mean the normal of the plane should point to that cone vertex? or? Commented Nov 8, 2017 at 13:48
• Rotating around what?
– Maxx
Commented Nov 8, 2017 at 14:14
• @Maxx, Origin point of plane. It's shown in first picture. Commented Nov 8, 2017 at 14:25
• Ok. Why do you need it via scripting? Are you assuming it can't be done otherwise? Or do you really need it via scripting (for instance, you are developing an addon)?
– Maxx
Commented Nov 8, 2017 at 14:54
• @Maxx, No I am trying to automatise a process that I do everyday by hand. :) Commented Nov 8, 2017 at 15:37

Here is how I would do it. I'll just show a workflow for doing it with constraints and blender operators. I assume you will manage to code the same process in python?

I add an empty which is the point you want to track. I had a child cone for consistency with your image ;-).

I add another empty with a set of contraints :

And then I add a constraint to the plane's object :

It is over, the plane is like you want. Now you can either leave it as is. You can move the first empty, and the plane will follow it. Or, you can select your plane, and "Apply visual transform". And then you can delete everything you don't want anymore.

Now you can do these steps in python ! I guess it is slower than computing directly the good rotation with some trigonometry, but it has the avantage og being simple, plus you can still move your point at the end !

• I didn't know how to put a point with directions, so I used a cone :D Commented Nov 8, 2017 at 16:45