Server Bug Fix: Proportionally editing an object using a given/exact angle

Original Source Link

I can proportionally edit an object (see animation below) but if I want to alter an object to have an angle of 63.45 how can I go about calculating/doing this (I’m testing parameters/limits/tolerances for a 3D printer).

The measure tools are just giving a ball park range. I’m trying to be more exact and would like to type in the exact value needed to get the desired angle.

Animation

The measure tools are just giving a ball park range. I’m trying to be more exact and would like to type in the exact value needed to get the desired angle.

Image

First, make yourself aware of the trigonometrical relations.

$height = tan(alpha) = tan(63°)$

In python you can express this as

tan(radians(63))

This is the desired height. Add a cylinder, select the top edge loop and type the equation into the Z field. Upon pressing enter, the value will automatically be calculated.

equation in z field

Scale the top edge loop to 0, add a half sphere, add appropriate loop cuts if necessary, then merge the top circle into a single vertex.

enter image description here

Using the UI to find the code to script it

The transform translate operator depends on a number of things, other than just the amount translated, including the type of falloff and the radius of falloff.

enter image description here

After running an operator go to the info window and copy the last command. It will have the settings last chosen producing the shape we want, from the starting point of the default north pole vert.

enter image description here

Script below I’ve added an import and tabbed it out to clearly see the options chosen when translating Note haven’t made an effort here to choose good values for this example

import bpy

bpy.ops.transform.translate(
    value=(0, 0, 0.456083), 
    orient_type='GLOBAL', 
    orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), 
    orient_matrix_type='GLOBAL', 
    constraint_axis=(False, False, True), 
    mirror=True, 
    use_proportional_edit=True, 
    proportional_edit_falloff='SMOOTH', 
    proportional_size=0.82, 
    use_proportional_connected=False, 
    use_proportional_projected=False)

With the same “context” ie the sphere in edit mode and the top vert selected can run this script in text editor and it will do the same again, that is will translate the selected vert up again by the same amount. Vertices within the sphere of proportional edit size influence will come along for the ride.

Ok then, if we have a “fresh” UV sphere with the top vert selected we can be assured that the top vert is locally at the north pole (0, 0, 1) and the equator point chosen to measure angle is arbitrarily (-1, 0, 0) Will work in LOCAL coordinates

Similarly as also suggested by @Leander can work out our height, and henceforth the delta height to move based on the angle

dz = tan(angle) - 1

Zero when angle is 45 degrees. Could stop here and type tan(radians(63)) - 1 directly into operator value z field as shown by @Leander

Have chosen the proportional edit radius of root 2 sqrt(2). (ie affect all verts with coordinates within this radius from top vert. Using root 2 will create a proportional edit “sphere of influence” centered at north pole vert such that the equator of original is encompassed within (on surface) Blender isn’t that exact so to avoid some points on equator being in some out have added a tiny smidge to radius to allow for tolerance errors.)

A radius of 1 will produce a more pear shape. Changing the falloff type to linear a cone, to constant a capsule, etc.

Here is a test script to run on a default sphere in edit mode with only the top vert selected which moves, with proportional edit all verts equator up using the pole vert such that the zenith angle is reached.

import bpy
from math import radians, tan

angle = radians(63.45)
# for default sphere
dz = tan(angle) - 1 
#radius = 1 # more of a pear shape
radius = sqrt(2) 

bpy.ops.transform.translate(
    value=(0, 0, dz), 
    orient_type='LOCAL', 

    use_proportional_edit=True, 
    proportional_edit_falloff='SMOOTH', 
    proportional_size=radius + 1e-6, 
    use_proportional_connected=False, 
    use_proportional_projected=False)

The next step here could be to simply create a sphere, select its top vert in code before above, to create a shape based on the settings chosen. I’ll leave that for another day.

enter image description here
Result Left as posted, Centre radius 1, LINEAR falloff. Right radius root 2, SHARP falloff

I dont think there is a tool for this, but you could do the calculation to know how much your upper vertex has to move up, which you can type for precision, and arrange everything from there.

Tagged : /

Leave a Reply

Your email address will not be published. Required fields are marked *