1 # This program is free software; you can redistribute it and/or
2 # modify it under the terms of the GNU General Public License
3 # as published by the Free Software Foundation; either version 2
4 # of the License, or (at your option) any later version.
6 # This program is distributed in the hope that it will be useful,
7 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 # GNU General Public License for more details.
11 # You should have received a copy of the GNU General Public License
12 # along with this program; if not, write to the Free Software Foundation,
13 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15 File Browser: Libraries Bookmark
17 The "Libraries" panel on the File Browser displays the path to all the
18 libraries linked to that .blend. So you can quickly go to the folders
21 Click on any path to go to that directory.
22 Developed during Caminandes Open Movie Project
28 class AMTH_FILE_PT_libraries(bpy
.types
.Panel
):
29 bl_space_type
= "FILE_BROWSER"
30 bl_region_type
= "TOOLS"
31 bl_category
= "Bookmarks"
32 bl_label
= "Libraries"
34 def draw(self
, context
):
37 libs
= bpy
.data
.libraries
40 # Build the list of folders from libraries
44 directory_name
= os
.path
.dirname(lib
.filepath
)
45 libslist
.append(directory_name
)
47 # Remove duplicates and sort by name
48 libslist
= set(libslist
)
49 libslist
= sorted(libslist
)
51 # Draw the box with libs
57 for filepath
in libslist
:
60 row
.alignment
= "LEFT"
62 AMTH_FILE_OT_directory_go_to
.bl_idname
,
63 text
=filepath
, icon
="BOOKMARKS",
65 props
.filepath
= filepath
67 box
.label(text
="No libraries loaded")
70 class AMTH_FILE_OT_directory_go_to(bpy
.types
.Operator
):
72 """Go to this library"s directory"""
73 bl_idname
= "file.directory_go_to"
76 filepath
: bpy
.props
.StringProperty(subtype
="FILE_PATH")
78 def execute(self
, context
):
79 bpy
.ops
.file.select_bookmark(dir=self
.filepath
)
84 bpy
.utils
.register_class(AMTH_FILE_PT_libraries
)
85 bpy
.utils
.register_class(AMTH_FILE_OT_directory_go_to
)
89 bpy
.utils
.unregister_class(AMTH_FILE_PT_libraries
)
90 bpy
.utils
.unregister_class(AMTH_FILE_OT_directory_go_to
)