Say we want to navigate a tree structure without knowing all the data ahead of time, is it possible to do this in Blender?

For example, a menu which dynamically loaded a directory hierarchy from the filesystem (without having to scan the filesystem and generate a menu type for every directory ahead of time first).

  • 3
    $\begingroup$ Why is it necessarily a menu, instead of, for instance, a separated popup panel called from a menu? $\endgroup$ – lemon Jun 8 '18 at 15:52
  • 1
    $\begingroup$ @yhoyo make a menu of the file system where a subfolder expands as another menu. The templates menu in text editor is an example of this, to one level. If you put a new file in blender_path/2.79/scripts/templates it is added automatically to the menu. As it is now, If you add a new folder into the templates folder, the files of the subfolder are added to the menu, but in the bottom level (along with the folder). The concept is to make the "New Folder" item, (and any folder) a menu so the menu > submenu> subsubmenu > item choice is: folder/subfolder/subsubfolder/file. $\endgroup$ – batFINGER Jun 12 '18 at 8:12
  • 1
    $\begingroup$ @batFINGER, I think this could be more simple if layout.menu was returning a menu object (so that a property value can be set on the corresponding class instance). Do you know why it is not the case (returns None)? $\endgroup$ – lemon Jun 14 '18 at 8:24
  • 1
    $\begingroup$ @lemon agreed.being able to pass properties in UI like you can to an operator would be bloody handy. On my linux build (the last time I spent too much time on this) I could register new menu classes (for subfolders) from the __init__ method, and set the filepath class property. Hopefully being able to pass props to menu, or have some ref to the parent menu, to submenu more effectively, is coming in 2.8. 8^) @yhoyo Here is a randomly expanding menu example $\endgroup$ – batFINGER Jun 14 '18 at 11:07
  • 1
    $\begingroup$ You may refer to the link below: https://blender.stackexchange.com/questions/110064/how-to-make-a-dynamically-expanding-menu-in-blender $\endgroup$ – Jerel Pong Dec 10 '18 at 17:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.