1 # SPDX-FileCopyrightText: 2019-2023 Blender Foundation
3 # SPDX-License-Identifier: GPL-2.0-or-later
6 File Browser: Libraries Bookmark
8 The "Libraries" panel on the File Browser displays the path to all the
9 libraries linked to that .blend. So you can quickly go to the folders
12 Click on any path to go to that directory.
13 Developed during Caminandes Open Movie Project
19 class AMTH_FILE_PT_libraries(bpy
.types
.Panel
):
20 bl_space_type
= "FILE_BROWSER"
21 bl_region_type
= "TOOLS"
22 bl_category
= "Bookmarks"
23 bl_label
= "Libraries"
26 def poll(cls
, context
):
27 return context
.area
.ui_type
== 'FILES'
29 def draw(self
, context
):
32 libs
= bpy
.data
.libraries
35 # Build the list of folders from libraries
39 directory_name
= os
.path
.dirname(lib
.filepath
)
40 libslist
.append(directory_name
)
42 # Remove duplicates and sort by name
43 libslist
= set(libslist
)
44 libslist
= sorted(libslist
)
46 # Draw the box with libs
52 for filepath
in libslist
:
55 row
.alignment
= "LEFT"
57 AMTH_FILE_OT_directory_go_to
.bl_idname
,
58 text
=filepath
, icon
="BOOKMARKS",
60 props
.filepath
= filepath
62 box
.label(text
="No libraries loaded")
65 class AMTH_FILE_OT_directory_go_to(bpy
.types
.Operator
):
67 """Go to this library"s directory"""
68 bl_idname
= "file.directory_go_to"
71 filepath
: bpy
.props
.StringProperty(subtype
="FILE_PATH")
73 def execute(self
, context
):
74 bpy
.ops
.file.select_bookmark(dir=self
.filepath
)
79 bpy
.utils
.register_class(AMTH_FILE_PT_libraries
)
80 bpy
.utils
.register_class(AMTH_FILE_OT_directory_go_to
)
84 bpy
.utils
.unregister_class(AMTH_FILE_PT_libraries
)
85 bpy
.utils
.unregister_class(AMTH_FILE_OT_directory_go_to
)