Python bpy_extras.io_utils.ImportHelper() Examples

The following are 3 code examples of bpy_extras.io_utils.ImportHelper(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module bpy_extras.io_utils , or try the search function .
Example #1
Source File: operator_file_import.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def read_some_data(context, filepath, use_some_setting):
    print("running read_some_data...")
    f = open(filepath, 'r', encoding='utf-8')
    data = f.read()
    f.close()

    # would normally load the data here
    print(data)

    return {'FINISHED'}


# ImportHelper is a helper class, defines filename and
# invoke() function which calls the file selector. 
Example #2
Source File: operator_file_import.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def read_some_data(context, filepath, use_some_setting):
    print("running read_some_data...")
    f = open(filepath, 'r', encoding='utf-8')
    data = f.read()
    f.close()

    # would normally load the data here
    print(data)

    return {'FINISHED'}


# ImportHelper is a helper class, defines filename and
# invoke() function which calls the file selector. 
Example #3
Source File: __init__.py    From io_kspblender with GNU General Public License v2.0 4 votes vote down vote up
def execute(self,context):
        scn = bpy.context.scene
        selected = bpy.context.selected_objects
        shippart = selected.pop(0)
        bpy.ops.object.select_all(action = 'DESELECT')
        shippart.select = True
        shipname = shippart["ship"]

        mergelist = []

        for obj in scn.objects:
            if obj.type == 'MESH' and obj["ship"] == shipname and not obj.hide:
                mergelist.append(obj)

        bpy.ops.object.select_all(action = 'DESELECT')         
        for obj in mergelist:
            obj.select = True
        
        bpy.ops.object.join()
        bpy.ops.object.parent_clear(type='CLEAR')
        result = bpy.context.active_object
        result.name = "RESULT"
        #result.scale = (10,10,10)
        bpy.ops.object.mode_set(mode='EDIT')
        bpy.ops.mesh.remove_doubles(threshold = 0.001)
        bpy.ops.mesh.normals_make_consistent(inside = False)
        bpy.ops.object.mode_set(mode='OBJECT')
        
        return {'FINISHED'}

##class LoadFlagPartOperator(bpy.types.Operator, ImportHelper):
##    bl_idname = "object.loadflag"
##    bl_label = "Load Flag"
##
##    filename_ext = "Image file"
##    filter_glob = StringProperty(default="*.jpg;*.JPG;*.jpeg;*.JPEG;*.png;*.PNG;*.bmp;*.BMP;*.tiff;*.TIFF", options={'HIDDEN'})
##    #Add more file types if necessary, I guess
##    
##    def execute(self, context):
##        from . import load_flag
##
##