Script below, named "km.py" and registered, works as expected for me on blender 2.8. It circle selects with set radius on C pressed and finishes on release.
Assumed the missing import bpy
in question script was a copy paste error, but it may be your issue. Always check the system console for errors.
Script:
import bpy
def custom_keymaps():
wm = bpy.context.window_manager
kc = wm.keyconfigs.addon
km = kc.keymaps.new('3D View', space_type='VIEW_3D', region_type='WINDOW', modal=False)
kmi = km.keymap_items.new("view3d.select_circle", "C", "PRESS")
kmi.properties.radius = 10
km = kc.keymaps.new(name='View3D Gesture Circle', space_type='VIEW_3D', region_type='WINDOW', modal=True)
kmi = km.keymap_items.new_modal('CANCEL', 'C', 'RELEASE', any=True)
custom_keymaps()
Only aesthetic changes re setting kmi
after creating a new item. (otherwise kmi
is set to the radius which is a little misleading) and calling the method directly rather than via register method. Script in question also works as expected with the import and calling register()
at level 0.
Given a py extension and register checked
How to auto-run a simple script?
If you are executing this in a registered script (sane text block name with .py extension and the register script checkbox ticked on text editor header) then same as answer here https://blender.stackexchange.com/a/134416/15543 also applies.
__name__
will be the sane textblock name without the python extension. When imported on register. Prob simpler to put register()
as the last line of script in this case.
Currently your unregister
method is also registering, however loading script this way will probably not trigger any unregisster activity.
You can import these into the python console. Let's imagine your script is called "foo.py" in the text editor then
import foo
foo.register()
will register it similarly to an addon. Later you can call
foo.unregister()
to unregister while seeing any errors printed into the python console.
PS if this is the case could possibly mark this q as a dupe.