# 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";
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)