Hello I am trying to create a list of blend files from a specific directory however I want to get the lists from a selected directory, which requires StringProperty to be used in the UI props. But in order to create a list, it needs to be initialized before def execute(self, context)
but in order to get the information for the directory e.g. context.scene.prop_tool.example_tool
, it requires it to be execute in the def execute(self, context)
or else it returns the error calling context
does not exist. How can I obtain the information for the properties without context?
example code:
class Properties(bpy.types.PropertyGroup):
items = ()
mytool = context.scene.my_tools #this code will not run due to this context outside execute
location = bpy.path.abspath(mytool.directory)
blends = [f for f in os.listdir(location) if f.endswith(".blend")]
for blend in blends:
blend_path = os.path.join(location, blend)
with bpy.data.libraries.load(blend_path) as (data_from, _):
for c in data_from.collections:
collitem = (c, c, "")
items = (collitem,) + items
local_search : EnumProperty(
name="Local Search",
items = items
)