I would like to make an simple angle label such as this:
![]()
using the python script to construct it.
The problem is trying to spin a MeshVertex, as the code looks for a Mesh object instead when using the bpy.ops.mesh.spin function.
The best method I have found to do this is to subdivide a small cylinder (vector) to get vertices, then select a vertice along the cylinder, then to spin it around the origin with some theta.
Here is the code I have so far, which does not work:
import bpy
import math
import os
import unicodedata
import bmesh
from bmesh.ops import spin
pi = math.pi
def lathe_geometry(bm, cent, axis, dvec, angle, steps, remove_doubles=True, dist=0.0001):
geom = bm.verts[:] + bm.edges[:]
# super verbose explanation.
spin(
bm,
geom=geom, # geometry to use for the spin
cent=cent, # center point of the spin world
axis=axis, # axis, a (x, y, z) spin axis
dvec=dvec, # offset for the center point
angle=angle, # how much of the unit circle to rotate around
steps=steps, # spin subdivision level
use_duplicate=0) # include existing geometry in returned content
if remove_doubles:
bmesh.ops.remove_doubles(bm, verts=bm.verts[:], dist=dist)
theta = pi/4
bpy.ops.mesh.primitive_cylinder_add( \
radius=0.01, \
depth = 5,
view_align=False, \
location = (0,5,0), \
rotation = (pi/2, pi/2, pi/2+theta))
c1 = bpy.context.scene.objects.active = bpy.data.objects['Cylinder']
c1.select = True
bpy.ops.object.mode_set(mode='EDIT', toggle=False)
bpy.ops.mesh.subdivide(number_cuts=10)
bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
c1.select = False
for el in c1.data.vertices:
el.select = False
vert = c1.data.vertices[3]
vert.select = True
bm = bmesh.new()
bm.from_mesh(c1.data)
axis = (1,0,0)
dvec = (0,0,0)
angle = 2*math.pi
steps = 20
cent = c1.location
lathe_geometry(bm, cent, axis, dvec, angle, steps, remove_doubles=True, dist=0.0001)
bm.to_mesh(c1.data)
bm.free()