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.

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

# 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:


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:

  1. In its invoke function you would create a circle curve object.
  2. In it's modal function you would change the U resolution of the curve and the scale, for instance based on mouse movement
  3. 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.

  • $\begingroup$ Thank you! I tried piemenus editor to create modal operator. I cant use curve circle, cause the U only power of 2, i need odd number of vertices too. Is there way to update bmesh, but retain loc rot scale $\endgroup$ – youthatninja Mar 20 '19 at 14:38

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.