i seem to be able to get the dynamic menus/enumProps working fine but it depends on what’s triggering them it seems. What im needing is for when i change one menu/enumProp the other one updates depending on what the first one changes to.
This is the code so far. Sorry it probably wont run because it relies on another class and its a bit bitsy at the moment. This runs no errors but the 2nd enumProp doesnt update…
import bpy
import os
from bpy.props import *
import px_project as pxp
asset_categories=[('CHARACTERS','Characters','Characters folder'),
('PROPS','Props','Props folder'),
('ENVIRONMENTS','Environments','Environments folder'),
('MATTES','Mattes','Mattes folder'),
]
class PxAssetLoader(bpy.types.Operator):bl_idname = "wm.asset_loader"
bl_label = "Asset Loader"
category_selection = "Props"
def set_category_selection(self, value):
[INDENT=2]self.category_selection = value[/INDENT]
def get_category_selection(self):
[INDENT=2]return (self.category_selection)[/INDENT]
def execute(self, context):
[INDENT=2]print('LOADED FILE')
return {'FINISHED'}[/INDENT]
# Runs when asset Loader has been selected from the Project Menu
def invoke(self, context, event):
[INDENT=2]return context.window_manager.invoke_props_dialog(self, width=300)[/INDENT]
def draw(self, context):
[INDENT=2]layout = self.layout
box = layout.box()
col = box.column()
col.label("Asset")
col.prop(context.scene, "Category")
col.separator()
col.prop(context.scene, "Asset")
col.separator()
#col.prop(self, "version_list_property")
col.separator()
col.separator()
[/INDENT]
# -----------------------------------------------------------------------------------------
asset_loader = PxAssetLoader
project_path = "/media/Podserver/01_Internal/00_RnD/CG_TestProject/Production/"
def create_asset_List(dir_path, target_folder):file_list = list()
file_names = list()
i=0
for filename in os.listdir(dir_path + target_folder):
[INDENT=2]file_names.append(filename)[/INDENT]
for each_file in file_names:
[INDENT=2]file_list.append(((each_file).upper(), each_file, str(i)))
i=i+1
[/INDENT]
return(file_list)
def get_category(self):return self['Category']
def set_category(self, value):self['Category'] = value
def get_asset(self):return self['Asset']
def set_asset(self, value):self['Asset'] = value
def update_category_property(self, context):# get selection index, use index to select asset type and split to get selection
category_index = get_category(self)
category_type = asset_categories[category_index]
selection = str(category_type).split("'")
print(selection[3])
asset_loader.set_category_selection(asset_loader,selection[3])
def update_asset_property(self, context):print(asset_loader.get_category_selection(asset_loader)) # test
bpy.types.Scene.Category = bpy.props.EnumProperty(items=asset_categories, get=get_category, set=set_category, update=update_category_property)
bpy.types.Scene.Asset = bpy.props.EnumProperty(items=create_asset_List(project_path, asset_loader.get_category_selection(asset_loader)), get=get_asset, set=set_asset, update=update_asset_property)
bpy.utils.register_class(PxAssetLoader)