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).

  • 1
    $\begingroup$ I think this question is really unclear and think you should edit it to make it more clear. $\endgroup$
    – Skylumz
    Jun 7, 2018 at 22:37
  • 3
    $\begingroup$ Why is it necessarily a menu, instead of, for instance, a separated popup panel called from a menu? $\endgroup$
    – lemon
    Jun 8, 2018 at 15:52
  • 2
    $\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, 2018 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, 2018 at 8:24
  • 2
    $\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, 2018 at 11:07


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.