Td Python Extensionのロゴ

Td Python Extension

組織
TouchDesigner
td-python-extension

Python extensions — extension classes, ext0object, parameter callbacks, lifecycle, state/persistence, scriptTOP/numpy. Use when building Python-driven baseCOMPs.

概要

公開者TouchDesigner
リポジトリTDMCPSkills
スキル名td-python-extension
スター
42
フォーク
1
同梱ファイル
2
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 2個の同梱ファイル

    モデルが作業中に読み取れるスクリプト、テンプレート、参考資料です。ファイルは読み取り専用で、実行されることはありません。

  • オープンソース

    TouchDesignerがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキルTd Python ExtensionをTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/TouchDesigner/TDMCPSkills/tree/main/skills/td-python-extension
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/TouchDesigner/TDMCPSkills.git /tmp/TDMCPSkills
mkdir -p .claude/skills
cp -r /tmp/TDMCPSkills/skills/td-python-extension .claude/skills/td-python-extension
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでTd Python Extensionを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあると、モデルが自動的にTd Python Extensionを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Td Python Extensionは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、未使用のスキルにはコストがかかりません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

Python Extensions

Patterns for Python extension components in TouchDesigner. Complements td-comp-architecture (structure/custom pars) and td-dat-family (callback mechanics). See reference.md for API signatures and examples.md for complete patterns.

Create an extension — one pass

The fixed choreography. Author the class (step 3) and verify (step 7); the rest is invariant. Mirrors what TD's own Component Editor produces.

  1. baseCOMP base_<x> — name it now; binding and docked refs snapshot at creation.
  2. textDAT <Name> inside — DAT = module = class, one identifier (e.g. SimpleExt).
  3. set_dat_content the Skeleton (below) → code/py/<comp-path>/<Name>.py.
  4. language=python — set it explicitly; set_dat_content doesn't (see Sync to File).
  5. ext0object = op('./<Name>').module.<Name>(me) + ext0promote=True — leave ext0name empty (promoted under the class name). ext0 always exists → no sequence management.
  6. pulse reinitextensions.
  7. Gate — not done until proven: get_errors clean AND a promoted member called from outside returns a value (op('base_<x>').Hello()). Print it.

Inspect an existing one: get_operator_info(path, include_extensions=true) — class names, promoted signatures, clone sources.

Naming & promotion

  • DAT == module == class — one identifier; Ext/EXT suffix optional. me.mod("<Name>").<Name>(me) is an equivalent shorthand for the step-5 binding.
  • Capitalized members = promoted (external via comp.Member); lowercase/underscore = internal.
  • Promotion exposes Capitalized methods; use @property (or TDF.createProperty) for promoted data.
  • Store self.ownerComp in __init__.

Skeleton

Bare MCP create(textDAT) gives you an empty DAT — author this skeleton (it mirrors TD's Component Editor template). Going through the Component Editor harvests it for you.

python
from TDStoreTools import StorageManager
import TDFunctions as TDF

class CounterExt:
	"""CounterExt description"""
	def __init__(self, ownerComp):
		self.ownerComp = ownerComp

		# Dependable property — cooks dependents when it changes
		TDF.createProperty(self, 'MyProperty', value=0, dependable=True, readOnly=False)

		self.a = 0   # internal attribute
		self.B = 1   # promoted attribute (Capitalized)

		# Persistent across saves AND re-initialization:
		storedItems = [
			{'name': 'StoredProperty', 'default': None, 'readOnly': False,
			 'property': True, 'dependable': True},
		]
		# self.stored = StorageManager(self, ownerComp, storedItems)

	def myFunction(self, v):        # internal
		debug(v)

	def PromotedFunction(self, v):  # external (Capitalized)
		debug(v)

	# def onInitTD(self):    # after all extensions attached — cross-ext deps
	# 	debug("onInitTD called")
	# def onDestroyTD(self): # cleanup; use instead of __del__
	# 	debug("onDestroyTD called")

Sync to File

The editor (and create) make the extension DAT embedded, not on disk. Getting it into the code-on-disk workflow is a follow-on step — one set_dat_content call writes the file and sets file/syncfile (it does NOT set language — set that yourself, step 4):

  • Path: code/py/<comp>/<subcomp>/<Name>.py — see td-dat-family for the canonical flow
  • After syncing, edit on disk; the DAT auto-re-inits on external edit (no reinitextensions).
  • Re-init wipes plain state. It runs __init__, so self.a-style attributes reset every edit. State that must survive re-init (and saves) belongs in StorageManager stored items (the self.stored block above), not plain attributes.

Parameter Callback Routing

Extension reacts to custom parameter changes via parameterexecuteDAT:

  • op = .., pars = *, builtin = False
  • Generic routing loops through par.owner.extensions calling onParValueChange / onParPulse
  • Without this DAT, the extension is deaf to parameter changes

Lifecycle

  • __init__(ownerComp) — creation/reinit, store refs, declare slots as None
  • onInitTD() — after all extensions attached, safe to access other exts
  • onDestroyTD() — cleanup (use instead of __del__)

Use onInitTD when depending on other components' extensions being ready.

State & Persistence

  • State lives on self — never on module globals. Module globals re-execute on reinit and lose state
  • TDF.createProperty (from import TDFunctions as TDF) for reactive/dependable state — list/panel callbacks reading ext.PropertyName auto-recook on change. Plain self.x = ... does NOT trigger downstream recooks. e.g. TDF.createProperty(self, 'MyProperty', value=0, dependable=True, readOnly=False)
  • StorageManager (from from TDStoreTools import StorageManager) for persistence across saves:
python
storedItems = [
    {'name': 'History', 'default': [], 'readOnly': False,
     'property': True, 'dependable': True},
]
self.stored = StorageManager(self, ownerComp, storedItems)

scriptTOP + numpy

copyNumpyArray() must run inside onCook — calling it elsewhere raises tdError.

Stage-and-cook: extension stages self._pixels, calls script_top.cook(force=True), scriptTOP onCook calls back into extension which runs copyNumpyArray.

Safe Operator Resolution

Custom parameters referencing operators (TOP, CHOP, etc.) may be empty or invalid. Always resolve safely — check for None and validate before using.

Internal Layout

Extension DAT and parameterexecuteDAT at X=-200 (left of origin). Main operator chain flows right from X=0. Output null at chain end.

DAT Module Imports

  • Same COMP: mod.datName or from datName import X (module-level only)
  • Cross COMP: op('comp').mod.datName — the only reliable pattern
  • Syncing a DAT to a file does NOT strip TD globals — a file-synced DAT is still a DAT, so op, me, project, debug, etc. are available (extensions sync to disk fine). The "no globals" caveat applies only to a plain .py imported as a module outside any DAT namespace.

Pitfalls

  • ext0object as expression — must be constant-mode string, not expression
  • ext0promote only promotes methods — not attributes; use @property for data
  • copyNumpyArray outside onCook — stage data on extension, call from onCook only
  • Language not set on extension DAT — always language=python
  • No parameterexecuteDAT — extension won't react to custom parameter changes
  • Module-level heavy imports — import torch/numpy in a setup method, not at module top
  • Name collision on create — TD silently appends numbers; verify .name matches requested
  • HTTP/urllib in main thread — blocks cook loop; use webClientDAT or run() with delayFrames
  • Forgetting reinitextensions (in-DAT edits only) — code edited inside the DAT doesn't reload until pulsed. A file-synced DAT auto-re-inits on external disk edit. Either way, re-init wipes plain attributes — persist anything that must survive via StorageManager (see Sync to File)
  • findChildren(type=textDAT) without maxDepth=1 — crawls into annotateCOMPs and other utility COMPs, triggering compilation of their internal DATs as Python. Always use maxDepth=1 when loading sibling modules
  • Assuming op reference pars are valid — always check for None before using

同梱ファイル

スキルが読み込まれている間、モデルは必要に応じてこれらを読み取ります。読み取り可能なファイルとして提供され、実行されることはありません。

よくある質問

AIスキル「Td Python Extension」では何ができますか?

Python extensions — extension classes, ext0object, parameter callbacks, lifecycle, state/persistence, scriptTOP/numpy. Use when building Python-driven baseCOMPs.

TypingMindでTd Python Extensionを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Td Python Extensionはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにTd Python Extensionをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/TouchDesigner/TDMCPSkills/tree/main/skills/td-python-extensionを貼り付けてください。TypingMindがSKILL.mdを読み込み、関連ファイルをまとめて、チャットごとに有効にできるスキルとしてインストールします。

Td Python Extensionを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストが合致したときにこのスキルを読み込めます。

Td Python Extensionは何個のAIモデルで使えますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもTd Python Extensionを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Td Python Extension」は無料ですか?

TouchDesignerがGitHubで公開しています。ライセンス条件はリポジトリでご確認ください。支払いが必要なのは、利用したトークンに対する、ご自身が契約するAIプロバイダーへの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇