Skip to content

Commit 3fdb41d

Browse files
committed
json - need to implement in all ops still
1 parent ed8b2f2 commit 3fdb41d

File tree

6 files changed

+81
-115
lines changed

6 files changed

+81
-115
lines changed

ops/add_categories_to_library.py

-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ def execute(self, context: bpy.types.Context) -> set[str]:
4747
hive_mind.load_categories()
4848

4949
with lib.open_catalogs_file() as cat_file:
50-
cat_file: utils.CatalogsFile
5150
for category_uuid, sub_list in hive_mind.SUBCATEGORIES_DICT.items():
5251
cat_info = hive_mind.CATEGORIES_DICT.get(category_uuid)
5352
cat = cat_file.find_catalog(category_uuid)

ops/add_to_library.py

+11-6
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,17 @@ def execute(self, context):
137137
/ self.new_library_name.replace(" ", "_").casefold()
138138
)
139139
dir.mkdir(parents=True, exist_ok=True)
140-
lib = utils.AssetLibrary.create_new_library(
140+
self.lib = utils.AssetLibrary.create_new_library(
141141
self.new_library_name, str(dir), context=context, load_catalogs=True
142142
)
143143
self.is_new_library = True
144144
else:
145-
lib = utils.from_name(self.library, context=context, load_catalogs=True)
145+
self.lib = utils.from_name(
146+
self.library, context=context, load_catalogs=True, load_assets=True
147+
)
146148
self.is_new_library = False
147149

148-
lib.path.mkdir(parents=True, exist_ok=True)
150+
self.lib.path.mkdir(parents=True, exist_ok=True)
149151

150152
assets = context.selected_assets
151153

@@ -155,11 +157,13 @@ def execute(self, context):
155157

156158
if self.keep_blend_files_as_is:
157159
self._thread = Thread(
158-
target=self.add_to_library_keep, args=(assets, lib.path)
160+
target=self.add_to_library_keep, args=(assets, self.lib.path)
159161
)
160162
# self.add_to_library_keep(assets, lib.path)
161163
else:
162-
self._thread = Thread(target=self.add_to_library_split, args=(assets, lib))
164+
self._thread = Thread(
165+
target=self.add_to_library_split, args=(assets, self.lib)
166+
)
163167
# self.add_to_library_split(assets, lib)
164168

165169
context.window_manager.modal_handler_add(self)
@@ -195,13 +199,15 @@ def finished(self, context: Context):
195199

196200
# try:
197201
utils.update_asset_browser_areas(context)
202+
self.lib.save_json()
198203
# except Exception as e:
199204
# print(f"An error occurred while refreshing the asset library: {e}")
200205

201206
return {"FINISHED"}
202207

203208
def follow_up(self):
204209
self.prog.end()
210+
205211
for area in bpy.context.screen.areas:
206212
area.tag_redraw()
207213

@@ -267,7 +273,6 @@ def add_to_library_split(
267273
self.updated = True
268274

269275
with lib.open_catalogs_file() as catfile:
270-
catfile: utils.CatalogsFile
271276
for catalog in catalogs:
272277
catfile.add_catalog_from_other(catalog)
273278

ops/asset_ops.py

-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ def execute(self, context):
4747
asset.catalog_id = cat.id
4848
else:
4949
with lib.open_catalogs_file() as cat_file:
50-
cat_file: "utils.CatalogsFile"
5150
if "/" in catalog_simple_name:
5251
name = catalog_simple_name.split("/")[-1]
5352
cat = cat_file.add_catalog(name, path=catalog_simple_name)

ops/remove_empty_catalogs.py

-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ def execute(self, context):
3333
print("No catalogs used in library")
3434

3535
with lib.open_catalogs_file() as cat_file:
36-
cat_file: utils.CatalogsFile
37-
3836
for cat in cat_file.get_catalogs():
3937
if cat.id not in catalog_ids and not cat.has_child(catalog_ids):
4038
cat.remove_self()

settings/scene.py

-1
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,6 @@ def process_asset_metadata(
654654
asset.catalog_id = cat.id
655655
if not cat:
656656
with lib.open_catalogs_file() as cat_file:
657-
cat_file: "utils.CatalogsFile"
658657
if "/" in catalog_simple_name:
659658
name = catalog_simple_name.split("/")[-1]
660659
cat = cat_file.add_catalog(

0 commit comments

Comments
 (0)