Creating mesh with "wait for input"

Hello
I want creat such a simple script.
Script is going to object mode, creat ico sphere, User is changing size of ico sphere, by new command like resize, and after he press lmb to accept new size, the next thing what script will make will added modifier Smooth.
I heart that there is such a thing like wait_for_input. But I don’t know when I can put it, or where ?
My script

    def execute(self, context):
        bpy.ops.object.mode_set(mode='OBJECT')   
        bpy.ops.mesh.primitive_ico_sphere_add(enter_editmode=False, location=(24.1231, -188.457, -593.71))     
        bpy.ops.object.modifier_add(type='SMOOTH')
        return {'FINISHED'}

I know that I should put bpy.ops.transform.resize but I don’t know how or where insert wait_for_input.
I just want to make that when I accept size, the next operation will be adding a Smooth.

Thanks for help
and greetings

On my phone so I can’t go into much detail, but the easiest way would be to use a modal operator. Put your call to get into object mode and create the sphere in the invoke function, and control the scale in the modal function. Check out the simple modal operator template for an example of how to do it.

1 Like

Thanks for tip.
I’m trying to do something, but It’s not so easy :frowning:
Greets

Ok, I have such a code:
‘’’
class Test(bpy.types.Operator):
bl_idname = “fp.test”
bl_label = “Test”
bl_options = {“REGISTER”, “UNDO”}

def modal(self, context, event):

    if event.type == 'LEFTMOUSE':
        bpy.ops.object.modifier_add(type='SMOOTH')

        return {'FINISHED'}

    elif event.type in {'RIGHTMOUSE', 'ESC'}:
        bpy.ops.object.mode_set(mode='OBJECT') 

        return {'CANCELLED'}

    return {'RUNNING_MODAL'}

def invoke(self, context, event):
    if context.object:
        bpy.ops.mesh.primitive_ico_sphere_add(enter_editmode=False, location=(0, 0, 0))  
        bpy.ops.object.mode_set(mode='EDIT')                      

        return {'RUNNING_MODAL'}
    else:
        self.report({'WARNING'}, "No active object, could not finish")
        return {'CANCELLED'}  

‘’’
I’m trying to do, that after I press LMB or RMB happen something more, but without results…
Greets

YESSSSSS

‘’’
class Test(bpy.types.Operator):
bl_idname = “fp.test”
bl_label = “Test”
bl_options = {“REGISTER”, “UNDO”}

def modal(self, context, event):


    if event.type == 'LEFTMOUSE':
        bpy.ops.transform.resize('INVOKE_DEFAULT')   
                 
        return {'RUNNING_MODAL'}

    elif event.type in {'RIGHTMOUSE', 'ESC'}:
        bpy.ops.object.mode_set(mode='SCULPT') 


        return {'CANCELLED'}

    return {'RUNNING_MODAL'}

‘’’
Done!!