I'm trying to produce the following ellipse as a surface or curve within blender with the following specifications.

The following dimensions, including the position of the origin in x,y,z coordinates will be known. For this image, it will be a flat plane in the x,y direction.

What's the best way or how do you go about coding this?



some minor clarifications - the width is a + b = 12.

How about if this was the scenario instead, when it's more skewed and doesn't look like a circle?

enter image description here


I found a solution! Use this code in the blender text editor:

import bpy
import math

#IMPORTANT : set 3d cursor to world origin    
bpy.context.area.spaces[1].cursor_location = (0.0, 0.0, 0.0)

#Add circle curve
bpy.ops.curve.primitive_bezier_circle_add(view_align=False, enter_editmode=False, location=(0, 0, 0), layers=(True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False))

#define variables
a = 10
b = 2
c = 3 # I use the half of c
d = 5

#Calculate width
width = a + b   #or width = a + d + b?

#Calculate horizontal distance from world origin of c
distance = b / 2

#Calculate height c for the circle
#x^2 + y^2 = 1, see Unit Circle
x = (distance / (width / 2)) * math.pi * 0.5  

cCircle = math.sqrt(1 - x**2)

#now we have to scale the height of the circle, so cCircle becomes c. And give its width.
factor = c / cCircle

bpy.ops.transform.resize(value=((width)/2, factor, 1), constraint_axis=(True, True, False), constraint_orientation='GLOBAL', mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1)

#Calculate location origin
originX = -((width) / 2 ) + b
originY = 0
originZ = 0

#Set 3d Cursor at Origin location
bpy.context.area.spaces[1].cursor_location = (originX, originY, originZ)

#Set origin to 3d cursor

#Move object to world origin
bpy.ops.transform.translate(value=((width/2) - b, 0, 0), constraint_axis=(True, False, False), constraint_orientation='GLOBAL', mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1, release_confirm=True)


I hope this helps!

| improve this answer | |
  • $\begingroup$ hello! thank you for that. It worked great. I had to make a minor modification; from bpy.context.area.spaces[1].cursor_location = (0.0, 0.0, 0.0) to bpy.context.scene.cursor_location = (0.0, 0.0, 0.0) somehow .area.spaces didn't work for me. $\endgroup$ – Albert Nov 14 '16 at 14:18
  • $\begingroup$ is it possible to achieve the alternative problem? :) $\endgroup$ – Albert Nov 14 '16 at 14:23
  • $\begingroup$ Yes, but then you must use the bezier curve. $\endgroup$ – float Nov 14 '16 at 14:29
  • $\begingroup$ You can do it manually or do you need a script for it? $\endgroup$ – float Nov 14 '16 at 14:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.