# 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
        for index, item in enumerate([p for p in bpy.data.collections
                                      if p.mumodelprops.type == 'prop']):
            if index == prop_item:
                return item
        return None

    def execute(self, context):
        prop = self.find_prop(context)
        self._enum_item_cache.clear()
        if prop:
            loc = context.scene.cursor.location
            muscene = context.scene.musceneprops
            if muscene.internal:
                loc = muscene.internal.matrix_world.inverted() * loc
            rot = Vector((0, 0, 0))
            scale = Vector((1, 1, 1))
            obj = instantiate_model(prop, prop.mumodelprops.name,
                                    loc, rot, scale)
            obj.muproperties.modelType = 'PROP'
            obj.parent = muscene.internal
            context.layer_collection.collection.objects.link(obj)
            return {'FINISHED'}
        else:
            return {'CANCELLED'}

    def invoke(self, context, event):
        self.store_mouse_cursor(context, event)
        context.window_manager.invoke_search_popup(self)
        return {'CANCELLED'}


# 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

        for index, item in enumerate([p for p in bpy.data.collections
                                      if p.mumodelprops.type == 'prop']):
            if index == prop_item:
                return item
        return None

    def execute(self, context):
        prop = self.find_prop(context)
        self._enum_item_cache.clear()
        if prop:
            loc = context.scene.cursor.location
            muscene = context.scene.musceneprops
            if muscene.internal:
                loc = muscene.internal.matrix_world.inverted() * loc
            rot = Vector((0, 0, 0))
            scale = Vector((1, 1, 1))
            obj = instantiate_model(prop, prop.mumodelprops.name,
                                    loc, rot, scale)
            obj.muproperties.modelType = 'PROP'
            obj.parent = muscene.internal
            context.layer_collection.collection.objects.link(obj)
            return {'FINISHED'}
        else:
            return {'CANCELLED'}

    def invoke(self, context, event):
        self.store_mouse_cursor(context, event)
        context.window_manager.invoke_search_popup(self)
        return {'CANCELLED'}


classes_to_register = (