Change circle segment depends on diameter I want to program a tool for checking radial parts of a mesh.

The idea is:
You push a button, the scripts add an object (circle) to the scene.
Then you grab it place it and when you scale this circle it changes segments depending on the diameter.

I'm stuck on this for now

import bpy
import bmesh
import math
import mathutils

class OPA(bpy.types.Operator):
# Make a new BMesh
    bm = bmesh.new()


# Add a circle XXX, should return all geometry created, not just verts.
    bmesh.ops.create_circle(
        bm,
        cap_ends=True,
        cap_tris=True,
        diameter=2,
        segments=8)

# Finish up, write the bmesh into a new mesh
    me = bpy.data.meshes.new("Mesh")
    bm.to_mesh(me)
    bm.free()


# Add the mesh to the scene
    scene = bpy.context.scene
    obj = bpy.data.objects.new("Object", me)
    obj.show_wire = True;
    obj.show_all_edges = True;
    obj.draw_type = "WIRE";
    scene.objects.link(obj)
    obj.location = bpy.context.scene.cursor_location


# Select and make active
    scene.objects.active = obj
    obj.select = True

    #while True:
        #if obj.select == 'True' and scene.objects.active == obj:

bpy.utils.register_class(OPA)
Your operator does nothing. It's missing an execute or invoke function.

To do what you want to do, you could create a modal operator:


In its invoke function you would create a circle curve object.
In it's modal function you would change the U resolution of the curve and the scale, for instance based on mouse movement
when confirming the modal, you would convert the curve to a mesh (if that is what you want)


Check the template scripts in Blender to understand how operators are structured.