- if self.selected_only:
- objs = context.selected_objects
- else:
- objs = context.scene.objects
- if self.visible_collections:
- collections = [c.collection for c in context.view_layer.layer_collection.children if not (c.hide_viewport or c.collection.hide_viewport)]
- objs = [o for o in objs if any((o.name in c.all_objects) for c in collections)]
- objs = [o for o in objs if o.type=="MESH" and not o.lod_for_parent]
- objs = [o for o in objs if (not o.compound or o.parent not in objs)]
- objs.sort(key=lambda x:x.name)
-
- path, base = os.path.split(out_fn)
- base, ext = os.path.splitext(base)
-
- from .export_object import ObjectExporter
- object_export = ObjectExporter()
-
- object_prototypes = {}
- unique_objects = []
- export_names = {}
- for o in objs:
- if o.name in object_prototypes:
- continue
-
- clones = [o]
- if not any(s.link=="OBJECT" for s in o.material_slots):
- for u in objs:
- if u is o:
- continue
- if u.data.name!=o.data.name:
- continue
- if any(s.link=="OBJECT" for s in u.material_slots):
- continue
-
- clones.append(u)
-
- prefix = o.name
- for c in clones:
- while not c.name.startswith(prefix):
- pos = max(prefix.rfind(' '), prefix.rfind('.'))
- if pos<0:
- break;
- prefix = prefix[:pos]
-
- if prefix:
- export_names[o.name+".object"] = prefix.strip(" .")+".object"
-
- unique_objects.append(o)
- for c in clones:
- object_prototypes[c.name] = o
-