# Path: prop/prop.py
# def loaded_props_collection():
#     return util_collection("loaded_props")
# 
# def make_prop(obj):
#     name = strip_nnn(obj.name)
#     obj.select_set(False)
#     prop = collect_objects("prop:"+name, obj)
#     obj.muproperties.modelType = 'PROP'
#     loc = Vector(obj.location)
#     rot = Quaternion(obj.rotation_quaternion)
#     scale = Vector(obj.scale)
#     parent = obj.parent
#     obj.location = Vector((0, 0, 0))
#     obj.rotation_quaternion = Quaternion((1, 0, 0, 0))
#     obj.scale = Vector((1, 1, 1))
#     obj.parent = None
#     prop.mumodelprops.name = name
#     prop.mumodelprops.type = "prop"
#     loaded_props = loaded_props_collection()
#     loaded_props.children.link(prop)
#     for c in bpy.data.collections:
#         if c == prop:
#             continue
#         for o in prop.objects:
#             if o.name in c.objects:
#                 c.objects.unlink(o)
#     obj = instantiate_model(prop, prop.mumodelprops.name, loc, rot, scale)
#     obj.muproperties.modelType = 'PROP'
#     bpy.context.layer_collection.collection.objects.link(obj)
#     obj.parent = parent
#     return obj


import os
import bpy
from bpy_extras.io_utils import ImportHelper
from mathutils import Vector, Quaternion
from bpy.props import StringProperty, EnumProperty
from ..preferences import Preferences
from ..cfgnode import ConfigNode, ConfigNodeError
from ..utils import strip_nnn
from ..model import instantiate_model
from .prop import loaded_props_collection, make_prop
    try:
        pass
        for obj in bpy.context.scene.objects:
            obj.select_set(False)
        prop = import_prop(filepath).get_model()
        context.layer_collection.collection.objects.link(prop)
        prop.location = context.scene.cursor.location
        prop.select_set(True)
        return {'FINISHED'}
    except:
        raise
    finally:
        bpy.context.preferences.edit.use_global_undo = undo

def clean_selected(selected):
    def ancestor_selected(o, sel):
        if not o:
            return False
        return ancestor_selected(o.parent, sel)
    objects = list(selected)
    for o in objects:
        if ancestor_selected(o, selected):
            selected.remove(o)

def make_props(self, context):
    operator = self
    undo = bpy.context.preferences.edit.use_global_undo
    bpy.context.preferences.edit.use_global_undo = False

    try:

# Path: prop/prop.py
# def loaded_props_collection():
#     return util_collection("loaded_props")
# 
# def make_prop(obj):
#     name = strip_nnn(obj.name)
#     obj.select_set(False)
#     prop = collect_objects("prop:"+name, obj)
#     obj.muproperties.modelType = 'PROP'
#     loc = Vector(obj.location)
#     rot = Quaternion(obj.rotation_quaternion)
#     scale = Vector(obj.scale)
#     parent = obj.parent
#     obj.location = Vector((0, 0, 0))
#     obj.rotation_quaternion = Quaternion((1, 0, 0, 0))
#     obj.scale = Vector((1, 1, 1))
#     obj.parent = None
#     prop.mumodelprops.name = name
#     prop.mumodelprops.type = "prop"
#     loaded_props = loaded_props_collection()
#     loaded_props.children.link(prop)
#     for c in bpy.data.collections:
#         if c == prop:
#             continue
#         for o in prop.objects:
#             if o.name in c.objects:
#                 c.objects.unlink(o)
#     obj = instantiate_model(prop, prop.mumodelprops.name, loc, rot, scale)
#     obj.muproperties.modelType = 'PROP'
#     bpy.context.layer_collection.collection.objects.link(obj)
#     obj.parent = parent
#     return obj


# Path: prop/operators.py
import os
import bpy
from bpy_extras.io_utils import ImportHelper
from mathutils import Vector, Quaternion
from bpy.props import StringProperty, EnumProperty
from ..preferences import Preferences
from ..cfgnode import ConfigNode, ConfigNodeError
from ..utils import strip_nnn
from ..model import instantiate_model
from .prop import loaded_props_collection, make_prop

    try:
        pass
        for obj in bpy.context.scene.objects:
            obj.select_set(False)
        prop = import_prop(filepath).get_model()
        context.layer_collection.collection.objects.link(prop)
        prop.location = context.scene.cursor.location
        prop.select_set(True)
        return {'FINISHED'}
    except:
        raise
    finally:
        bpy.context.preferences.edit.use_global_undo = undo

def clean_selected(selected):
    def ancestor_selected(o, sel):
        if not o:
            return False
        return ancestor_selected(o.parent, sel)
    objects = list(selected)
    for o in objects:
        if ancestor_selected(o, selected):
            selected.remove(o)

def make_props(self, context):
    operator = self
    undo = bpy.context.preferences.edit.use_global_undo
    bpy.context.preferences.edit.use_global_undo = False

    try:

        selected = set()