Index: release/scripts/io/import_scene_obj.py =================================================================== --- release/scripts/io/import_scene_obj.py (revision 27340) +++ release/scripts/io/import_scene_obj.py (working copy) @@ -517,7 +517,7 @@ -def split_mesh(verts_loc, faces, unique_materials, filepath, SPLIT_OB_OR_GROUP, SPLIT_MATERIALS): +def split_mesh(verts_loc, faces, unique_materials, unique_objects, filepath, SPLIT_OB_OR_GROUP, SPLIT_MATERIALS): ''' Takes vert_loc and faces, and seperates into multiple sets of (verts_loc, faces, unique_materials, dataname) @@ -530,7 +530,16 @@ # use the filename for the object name since we arnt chopping up the mesh. return [(verts_loc, faces, unique_materials, filename)] + # count materials and objects to see if we need to split + num_materials = 0 + for mat in unique_materials: + if mat != None and mat != "(null)": num_materials +=1 + if num_materials == 0 and len(unique_objects) == 0: + # don't split if there are no groups to split into + return [(verts_loc, faces, unique_materials, filename)] + + def key_to_name(key): # if the key is a tuple, join it to make a string if type(key) == tuple: @@ -1039,7 +1048,9 @@ unique_materials= {} unique_material_images= {} unique_smooth_groups= {} - # unique_obects= {} - no use for this variable since the objects are stored in the face. + # unique_objects only used to control splitting + # since objects are stored in the face. + unique_objects= {} # when there are faces that end with \ # it means they are multiline- @@ -1174,7 +1185,7 @@ elif line.startswith('o'): if SPLIT_OBJECTS: context_object= line_value(line.split()) - # unique_obects[context_object]= None + unique_obects[context_object]= None elif line.startswith('g'): if SPLIT_GROUPS: @@ -1288,7 +1299,7 @@ if SPLIT_OBJECTS or SPLIT_GROUPS: SPLIT_OB_OR_GROUP = True else: SPLIT_OB_OR_GROUP = False - for verts_loc_split, faces_split, unique_materials_split, dataname in split_mesh(verts_loc, faces, unique_materials, filepath, SPLIT_OB_OR_GROUP, SPLIT_MATERIALS): + for verts_loc_split, faces_split, unique_materials_split, dataname in split_mesh(verts_loc, faces, unique_materials, unique_objects, filepath, SPLIT_OB_OR_GROUP, SPLIT_MATERIALS): # Create meshes from the data, warning 'vertex_groups' wont support splitting create_mesh(scene, new_objects, has_ngons, CREATE_FGONS, CREATE_EDGES, verts_loc_split, verts_tex, faces_split, unique_materials_split, unique_material_images, unique_smooth_groups, vertex_groups, dataname)