def load(operator, context, **keywords):
    time_main = time.time()

    filepath = keywords['filepath']

	# Get rid of all existing objects in the scene
    for obj in bpy.context.scene.objects:
        obj.select = obj.type == 'MESH' or obj.type == 'EMPTY'
    bpy.ops.object.delete()

    # Process MDL file
    if filepath != None and os.path.splitext(filepath)[1][1:].strip() == "mdl":
        mdl = MDL(filepath)
        mdl.build_blender_scene(context, keywords['use_animations'])
        mdl.print_type()
    # Process DEF file
    elif filepath != None and os.path.splitext(filepath)[1][1:].strip() == "def":
        mowdef = MOWDEF(filepath)
        mowdef.build_blender_scene(context, keywords['use_animations'])
        mowdef.print_type()
    else:
        print("No .DEF file found")

    time_new = time.time()

    print("finished importing: %r in %.4f sec." % (filepath, (time_new - time_main)))
    return {'FINISHED'}
Beispiel #2
0
def load(operator, context, **keywords):
    time_main = time.time()

    filepath = keywords['filepath']

    # Get rid of all existing objects in the scene
    for obj in bpy.context.scene.objects:
        obj.select = obj.type == 'MESH' or obj.type == 'EMPTY'
    bpy.ops.object.delete()

    # Process MDL file
    if filepath != None and os.path.splitext(filepath)[1][1:].strip() == "mdl":
        mdl = MDL(filepath)
        mdl.build_blender_scene(context, keywords['use_animations'])
        mdl.print_type()
    # Process DEF file
    elif filepath != None and os.path.splitext(
            filepath)[1][1:].strip() == "def":
        mowdef = MOWDEF(filepath)
        mowdef.build_blender_scene(context, keywords['use_animations'])
        mowdef.print_type()
    else:
        print("No .DEF file found")

    time_new = time.time()

    print("finished importing: %r in %.4f sec." % (filepath,
                                                   (time_new - time_main)))
    return {'FINISHED'}