keep hierarchy option

This commit is contained in:
2026-02-19 18:06:25 +01:00
parent 6af9567a44
commit cbbe8be0d8
3 changed files with 182 additions and 6 deletions
+16 -5
View File
@@ -103,6 +103,7 @@ class Packer:
noop=False,
compress=False,
relative_only=False,
keep_hierarchy=False,
) -> None:
self.blendfile = bfile
self.project = project
@@ -111,6 +112,7 @@ class Packer:
self.noop = noop
self.compress = compress
self.relative_only = relative_only
self.keep_hierarchy = keep_hierarchy
self._aborted = threading.Event()
self._abort_lock = threading.RLock()
self._abort_reason = ""
@@ -241,9 +243,12 @@ class Packer:
# network shares mapped to Windows drive letters back to their UNC
# notation. Only resolving one but not the other (which can happen
# with the abosolute() call above) can cause errors.
bfile_pp = self._target_path / bfile_path.relative_to(
bpathlib.make_absolute(self.project)
)
if self.keep_hierarchy:
bfile_pp = self._target_path / bpathlib.strip_root(bfile_path)
else:
bfile_pp = self._target_path / bfile_path.relative_to(
bpathlib.make_absolute(self.project)
)
self._output_path = bfile_pp
self._progress_cb.pack_start()
@@ -335,7 +340,10 @@ class Packer:
self._new_location_paths.add(asset_path)
else:
log.debug("%s can keep using %s", bfile_path, usage.asset_path)
asset_pp = self._target_path / asset_path.relative_to(self.project)
if self.keep_hierarchy:
asset_pp = self._target_path / bpathlib.strip_root(asset_path)
else:
asset_pp = self._target_path / asset_path.relative_to(self.project)
act.new_path = asset_pp
def _find_new_paths(self):
@@ -346,7 +354,10 @@ class Packer:
assert isinstance(act, AssetAction)
relpath = bpathlib.strip_root(path)
act.new_path = pathlib.Path(self._target_path, "_outside_project", relpath)
if self.keep_hierarchy:
act.new_path = pathlib.Path(self._target_path, relpath)
else:
act.new_path = pathlib.Path(self._target_path, "_outside_project", relpath)
def _group_rewrites(self) -> None:
"""For each blend file, collect which fields need rewriting.