I have an object here with 2 faces (front and back) perpendicular to the floor and perfectly aligned with front ortho, then a number of smaller faces on all sides.

In front ortho, it looks like this

front ortho view

From the side, it looks like this

perspective view

I would like to use a script to get the angle of each side face, and then rotate it according to what angle it’s originally at.

The angle should be the angle between the face and the floor. Please share your advice on how I could go about this, thanks in advance


1 Answer 1


I think that the rotation manipulates vertices' location, so my option would be to check vertices' locations and their alignment correspondingly to the axes.

Example 1: (align to the X-axis) (View from the top) Here I picked 2 vertices of the face (V1 and V2)
A and B angles between the V1-V2 Edge and blue lines

Simply put:
if we want the V1-V2 Edge to be perpendicular to the X-axis, we should rotate it with B angle degrees; enter image description here

if parallel, then with A angle degrees. enter image description here

The same can be implemented correspondingly to other axes

Getting angles:
As long as we know V1 and V2 Location values, angles A and B can be calculated using sin.

As an example of aligning to the X-axis, here is what we can do: enter image description here

This is the base method, any of the given info can be found on the internet including the formulas to use in the script.

  • $\begingroup$ Thank you, I’ll have a look and come back to this. However if I manage to get the maths done, is bpy.ops.transform.rotate() the method I should be using? Or is there a more standard way $\endgroup$ Jun 14, 2022 at 7:37
  • $\begingroup$ b3d.interplanety.org/en/… - for rotating without bpy.ops. Make sure you use appropriate axes and coordinates for defining distances and degrees. If you have any problems on writing the script - feel free to reply and ask, and I will get into as sooner as I can $\endgroup$
    – kemplerart
    Jun 14, 2022 at 7:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .