From 17127fc77893b5903fa461f4c8a8fab30e6ae786 Mon Sep 17 00:00:00 2001 From: Hare Date: Wed, 4 Feb 2026 21:49:33 +0900 Subject: [PATCH] fix: transform --- operators.py | 35 ++++++++++++++++++++++++++++------- subtitles.py | 25 ++++++++++++++++++++++++- 2 files changed, 52 insertions(+), 8 deletions(-) diff --git a/operators.py b/operators.py index 69bfc24..a375b12 100644 --- a/operators.py +++ b/operators.py @@ -62,15 +62,16 @@ def get_text_strip_settings(context): # bl_rna.propertiesから全プロパティを取得 if hasattr(text_strip, 'bl_rna') and hasattr(text_strip.bl_rna, 'properties'): + # デバッグ: すべてのプロパティ名を出力 + all_prop_names = [p.identifier for p in text_strip.bl_rna.properties] + print(f"[VoiceVox Debug] 利用可能なプロパティ: {all_prop_names}") + for prop in text_strip.bl_rna.properties: prop_name = prop.identifier # スキップするプロパティ if prop_name in skip_properties: - continue - - # 読み取り専用プロパティはスキップ - if prop.is_readonly: + print(f"[VoiceVox Debug] スキップ(skip_properties): {prop_name}") continue # プロパティの値を取得 @@ -84,10 +85,30 @@ def get_text_strip_settings(context): settings['position_y'] = value[1] except (TypeError, IndexError): pass + # transformは子プロパティを個別にコピー(readonly だが子プロパティは書き込み可能) + elif prop_name == 'transform': + print(f"[VoiceVox Debug] transform プロパティを発見: {value}") + if hasattr(value, 'bl_rna') and hasattr(value.bl_rna, 'properties'): + print(f"[VoiceVox Debug] transform の子プロパティを列挙中...") + for transform_prop in value.bl_rna.properties: + transform_prop_name = transform_prop.identifier + if transform_prop.is_readonly: + continue + try: + transform_value = getattr(value, transform_prop_name) + settings[f'transform_{transform_prop_name}'] = transform_value + print(f"[VoiceVox] コピー: transform.{transform_prop_name} = {transform_value}") + except Exception as e: + print(f"[VoiceVox] transform.{transform_prop_name} の取得をスキップ: {e}") + else: + print(f"[VoiceVox Debug] transform に bl_rna.properties がありません") else: - settings[prop_name] = value - - print(f"[VoiceVox] コピー: {prop_name} = {value}") + # 通常のプロパティ: readonlyはスキップ + if prop.is_readonly: + print(f"[VoiceVox Debug] スキップ(readonly): {prop_name}") + else: + settings[prop_name] = value + print(f"[VoiceVox] コピー: {prop_name} = {value}") except Exception as e: print(f"[VoiceVox] {prop_name} の取得をスキップ: {e}") diff --git a/subtitles.py b/subtitles.py index 0aad3df..08a7a10 100644 --- a/subtitles.py +++ b/subtitles.py @@ -73,8 +73,20 @@ class SubtitleManager: position_x = all_settings.pop('position_x', 0.5) position_y_val = all_settings.pop('position_y', position_y) - # 全てのプロパティを設定 + # Transform関連のプロパティを分離 + transform_settings = {} + other_settings = {} + for prop, value in all_settings.items(): + if prop.startswith('transform_'): + # transform_offset_x → offset_x + transform_prop_name = prop[len('transform_'):] + transform_settings[transform_prop_name] = value + else: + other_settings[prop] = value + + # 通常のプロパティを設定 + for prop, value in other_settings.items(): try: setattr(text_strip, prop, value) print(f"[Subtitle] 設定: {prop} = {value}") @@ -91,6 +103,17 @@ class SubtitleManager: except (AttributeError, TypeError) as e: print(f"[Subtitle] location プロパティは利用できません: {e}") + # Transformプロパティを設定 + if transform_settings and hasattr(text_strip, 'transform'): + for prop, value in transform_settings.items(): + try: + setattr(text_strip.transform, prop, value) + print(f"[Subtitle] 設定: transform.{prop} = {value}") + except AttributeError: + print(f"[Subtitle] transform.{prop} プロパティは利用できません(スキップ)") + except Exception as e: + print(f"[Subtitle] transform.{prop} の設定に失敗: {e}") + print(f"Subtitle added: '{text}' at frame {frame_start}") return text_strip