class MOWDEF_NODE_EXTENSION(MOWDEF_NODE): def __init__(self, parent): self.mdl = None super(MOWDEF_NODE_EXTENSION, self).__init__(parent) def blender_get_root_object(self): if self.mdl: return self.mdl.blender_get_root_object() return None def load_data(self): super(MOWDEF_NODE_EXTENSION, self).load_data() from mowdef_node_root import MOWDEF_NODE_ROOT filename = None # Get the name of the MDL file filename = self.data.split()[1][1:-1] # Build a complete filepath to the .MDL file filename = self.path + filename print(type(self).__name__ + " Loading file " + filename) try: # Create an MDL object and load the MDL file self.mdl = MDL(filename) except: print(sys.exc_info()[0]) def build_blender_scene(self, blender_context, use_animations): if self.mdl: self.mdl.build_blender_scene(blender_context, use_animations)
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'}
class MOWDEF_NODE_EXTENSION(MOWDEF_NODE): def __init__(self, parent): self.mdl = None super(MOWDEF_NODE_EXTENSION, self).__init__(parent) def blender_get_root_object(self): if self.mdl: return self.mdl.blender_get_root_object() return None def load_data(self): super(MOWDEF_NODE_EXTENSION, self).load_data() from mowdef_node_root import MOWDEF_NODE_ROOT filename = None # Get the name of the MDL file filename = self.data.split()[1][1:-1] # Build a complete filepath to the .MDL file filename = self.path + filename print(type(self).__name__ + " Loading file " + filename) try: # Create an MDL object and load the MDL file self.mdl = MDL(filename) except: print(sys.exc_info()[0]) def build_blender_scene(self, blender_context, use_animations): if self.mdl: self.mdl.build_blender_scene(blender_context, use_animations)
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'}