Skip to content

Commit

Permalink
fix(motion path from curves): save location and making the actual array
Browse files Browse the repository at this point in the history
  • Loading branch information
NMC-TBone committed Dec 13, 2024
1 parent b50eb8c commit aac38dd
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions i3d_exporter_additionals/tools/generate_empty_on_curves.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,22 @@ def _create_empties_on_curve(self, context, hierarchy="curveArray"):
hierarchy_empty = self._create_empty(context, name=hierarchy)

if giants_i3d:
import os
from pathlib import Path
blend_file_path = Path(bpy.data.filepath).parent
target_path = Path(i3dea.motion_save_location if i3dea.motion_save_location else "")
relative_path = Path(os.path.relpath(target_path, blend_file_path))
relative_path = str(relative_path).replace('\\', '/')
final_path = f"{relative_path}/{hierarchy}.dds"
target_path = Path(i3dea.motion_save_location or "")

if blend_file_path.anchor == target_path.anchor:
try:
relative_path = target_path.relative_to(blend_file_path)
final_path = f"{relative_path.as_posix()}/{hierarchy}.dds"
except ValueError:
# Fallback to absolute path if relative fails
final_path = f"{target_path.as_posix()}/{hierarchy}.dds"
else:
# Use absolute path if paths are on different mounts
final_path = f"{target_path.as_posix()}/{hierarchy}.dds"

final_path = final_path.replace('\\', '/').replace('//', '/')

if not final_path.startswith((".", "/")):
final_path = "./" + final_path
Expand All @@ -137,7 +146,8 @@ def _create_empties_on_curve(self, context, hierarchy="curveArray"):
pose_empty = None

# For AMOUNT_FIX
curve_lengths = {curve: get_curve_length(curve) for curve in pose.sub_pose_list}
curve_lengths = {curve.curve: get_curve_length(context.scene.objects[curve.curve])
for curve in pose.sub_pose_list}
longest_curve_length = max(curve_lengths.values(), default=0)

for idx, curve in enumerate(pose.sub_pose_list):
Expand Down

0 comments on commit aac38dd

Please sign in to comment.