I like to use the function knife_project() in a command line :

blender.exe --background --python ...

but bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1) isn't avaible.

I try to use modal function, operator function but knife angle is always bad.

code is :

    def execute(self, context):

    bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
    # returns first 3d view, normally we get from context
    def view3d_find( return_area = False ):
        # returns first 3d view, normally we get from context
        for area in bpy.context.window.screen.areas:
            if area.type == 'VIEW_3D':
                v3d = area.spaces[0]
                rv3d = v3d.region_3d
                for region in area.regions:
                    if region.type == 'WINDOW':
                        if return_area: return region, rv3d, v3d, area
        return None, None

    region, rv3d, v3d, area = view3d_find(True)
    override = {
        'scene'            : bpy.context.scene,
        'region'           : region,
        'area'             : area,
        'space'            : v3d,
        'active_object'    : bpy.context.object,
        'window'           : bpy.context.window,
        'screen'           : bpy.context.screen,
        'selected_objects' : bpy.context.selected_objects,
        'edit_object'      : bpy.context.object
    rv3d.view_rotation = Euler( (0,0,0) ).to_quaternion()
    rv3d.view_perspective = 'ORTHO'
    bpy.data.objects["Grid"].select = True

    #bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1)

    bpy.ops.mesh.knife_project(override, cut_through=True)

    return {'FINISHED'}

Is there a way to replace redraw_timer ?

Best Regards,


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.