Flame user of 10+ yrs but new to the forum and it’s great what you’re doing here!
Total newbie with python scripts and I’m just starting with some real basics, like creating a bespoke set of libraries and subfolders in a fresh project. I think I’ve nailed it (thanks to @andymilkis and @fredwarren for Logik Live Ep #07)… apart from deleting the automatically-generated Default Library. Any pointers please?
The default library could probably be at any index. I would either iterate over all libraries to find it or use the build in function from the flame module to find it.
Find by iterating over all libs:
for lib in flame.project.current_project.current_workspace.libraries:
if lib.name.get_value() == "Default Library":
flame.delete(lib)
Find by using the flame module’s function:
for lib in flame.find_by_name("Default Library"):
# make sure we are really dealing with a lib and not any other item that is just called "Default Library"
if isinstance(lib, flame.PyLibrary):
flame.delete(lib)
Thanks both. Out of the 3 options I could only get the iteration over all libs working, but that’s done it!
When I get more time I’ll work out how to make the other options work. It’s pretty heavy going when you’re this new to python.
Thanks again
Hi all,
I have a similar request, I’m hoping to get the library name that contains the sequence I’m exporting to use in the file path.
Tried all variations on current library but no joy.
Any ideas?
If the sequence is on your current desk and you want to find the library where it has also been saved you probably need to crawl all libraries to find the sequence. Have a look at this code snippet which shows you how to collect clips from libraries with an unknown level of subfolders:
Instead of just adding every clip (clips.append(clip)) you would add a check if the clip name equals your clip name.
Thanks for you help Claus,
The clip will always be in a library.
Had a look at the link and can return lots of sequence info but don’t see any way to get which library its saved in.
Coming back to first question, I’m trying to use find_by_name method and I would need return the name of founded items. According with the succint help, it seems that this function returns a list. Taking the second example, I tried to print the list with something like:
for lib in flame.find_by_name("Default Library"):
if isinstance(lib, flame.PyLibrary):
print(lib[:])
but it does not work.
Also, I wonder if find_by_name method can use * or so, to perform basic searchs, to find, for example, all libraries started by “tmp”
As part of a script project, I’m using a temp library. I would like delete it after finishing the script. So I want to check if some temp libraries exist, and delete it, printing it in console with something like ´temp library deleted´ . And beyond, also check if temp 1 , temp 2 exist, and delete all of them.
for lib in flame.project.current_project.current_workspace.libraries:
if lib.name in ['temp 1', 'temp 2']:
flame.delete(lib)
print('Temp library deleted')
Sorry, I did not explain well. I meant that I wanted to print on the screen the actual names of the libraries founded.
But your answer gave me the right and simply answer. The right object is lib.name.
So it would be:
for lib in flame.find_by_name("temp"):
if isinstance(lib, flame.PyLibrary):
print(lib.name, ' library deleted')
… and it works.
I know it doesn’t make sense if I am looking for a specific name. But I was thinking if I could find more variations of that name (temp 1 , temp2 , temp whatever … and so on) with some procedural way and display the precise information about what was founded and deleted.
I don’t think find_by_name supports things like ´’temp*’ . I suppose I could try an if statement like you propose but with some kind of regular expression to make it more procedural.