I’m new to Python and thought it was easy but no luck yet…
Plan to write the code that create folder in Library with current date as it’s name by context menu selection, like those examples (Create Share Library and Create Batch, etc.). Is it possible to name the folder as what token_name do (i.e.
)?
Hoping to save some time when checking the date and typing on every folder creation…Any hint or suggestion will be very welcome~
Thanks Mike for your great input ! Glad to be able to continue the Python journey~
Due to my “embryo” status of Python, I can only follow those examples from Flame document and Mike’s hint, now it works when any Library selected. Although it’s not exactly as what I want but a starting point so I share here in case…
if you don’t want to create the folders in the currently selected library, but always in the same (in my case I call it “EXPORT”), you can do something like this:
EXPORT_LIB = "EXPORT"
def current_workspace():
"""Get the current workspace."""
return flame.project.current_project.current_workspace
def create_export_lib():
"""Create a new library for the export or return an existing one.
Returns:
PyLibrary: The library for the exports.
"""
workspace = current_workspace()
for lib in workspace.libraries:
if lib.name.get_value() == EXPORT_LIB:
return lib
return workspace.create_library(EXPORT_LIB)
# usage:
export_lib = create_export_lib()
# now you can create your folder here with your previous methods
export_lib.create_folder(folder_name)
Hi @claussteinmassl
Great thanks for your input. It’s looked way more advanced than my current ability but good for studying and learning from. Appreciate!!