Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Next Design Python Extension TemplateNew to Visual Studio Code? Get it now.
Next Design Python Extension Template

Next Design Python Extension Template

DENSO CREATE

|
1 install
| (0) | Free
Generate Python extension templates for Next Design
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Next Design Python Extension Template

Next Design Python Extension Template は、Next Design 向けの Python エクステンションテンプレートを自動生成する VS Code 拡張機能です。コマンド1つで、リボンUI定義・イベントハンドラ・APIスタブを含むテンプレートをすぐに生成できます。


機能

🛠️ "Generate ND Extension(Python)"

コマンドパレットから Generate ND Extension(Python) を実行すると、選択したフォルダ内に以下のテンプレート一式が生成されます。

PythonSampleExtension/
├── main.py                             # エントリーポイント(サンプル実装付き)
├── manifest.json                       # マニフェストファイル
├── nd/
│   ├── core.pyi                        # Core API スタブ(インテリセンス用)
│   ├── desktop.pyi                     # Desktop API スタブ(インテリセンス用)
│   ├── manifest.schema.json            # マニフェストスキーマファイル
│   └── __init__.pyi
└── extensionpoints/                    # 拡張ポイント構築ライブラリ
    ├── __init__.py
    ├── events/
    │   ├── application_event.py
    │   ├── commands_event.py
    │   ├── editors_event.py
    │   ├── informations_event.py
    │   ├── models_event.py
    │   ├── navigators_event.py
    │   ├── pages_event.py
    │   ├── project_event.py
    │   └── scm_event.py
    └── ribbon/
        ├── ribbon.py
        ├── ribbon_base.py
        ├── ribbon_controls.py
        ├── ribbon_group.py
        └── ribbon_tab.py

nd/ フォルダはAPIのインテリセンス情報を提供します。削除・変更を行うと補完機能が失われます。エクステンション自体の動作には影響しませんが、開発時には必須です。


使用方法

  1. コマンドパレットを開く
    Ctrl+Shift+P を押してコマンドパレットを開きます。

  2. コマンドを実行
    Generate ND Extension(Python) を選択します。

  3. 生成先フォルダを選択
    フォルダ選択ダイアログで親フォルダを指定します。選択したフォルダ内に PythonSampleExtension/ フォルダが作成されます。

  4. 開発開始
    生成完了後、フォルダを開く ボタンで VS Code に生成フォルダを開き、開発を始めます。

選択したフォルダに既存の PythonSampleExtension/ が存在する場合、上書き確認のダイアログが表示されます。


生成されるサンプルコード

main.py

エクステンションのエントリーポイントです。リボンタブへのボタン追加、コマンドハンドラ、イベントハンドラのサンプルが含まれています。

from nd import *
from extensionpoints import *

extension_points = None

def on_activate(c):
    global extension_points

    # エクステンションポイントの初期化
    nd_extension = c.ExtensionInfo
    extension_points = ExtensionPoints(nd_extension)

    # リボンタブの追加
    ribbon = extension_points.ribbon
    new_tab = ribbon.add_tab("PythonSample.MainTab", "Python Sample")
    new_tab.order_before = RibbonTabs.VIEW

    # タブにグループとボタンを追加
    new_group = new_tab.add_group("PythonSample.MainGroup", "Main")
    new_group.add_large_button("Sample Command", "error_check", id="PythonSample.SampleButton")

    # イベントハンドラの登録
    events = extension_points.events
    model_field_event = events.add_model_event_subscription()
    model_field_event.on_field_changed = "name_check"

# コマンドハンドラ: 名前が空のモデルにエラーを追加する
def error_check(context: ICommandContext, command_params: ICommandParams):
    app = context.App
    app.Workspace.Output.WriteLine("Sample", "エラーをチェックします..")
    for model in app.Workspace.CurrentModel.GetAllChildren():
        if model.GetField("Name") == "":
            model.AddError("Name", "Error", "検証エラー", "Nameが空です")
            break

# イベントハンドラ: Nameフィールドに"TBD"が含まれる場合にエラーを追加する
def name_check(context: IEventContext, event_params: IEventParams):
    if not isinstance(event_params, ModelFieldChangedEventParams):
        return
    if event_params.Field != "Name":
        return
    model = event_params.Model
    app = context.App
    app.Workspace.Errors.ClearErrorsAt(model)
    if "TBD" in model.Name:
        model.AddError("Name", "Error", "名前チェック", "TBDが含まれています")

def on_deactivate(c):
    global extension_points
    if extension_points is not None:
        extension_points.unregister_all()
        extension_points = None

manifest.json

エクステンションの定義ファイルです。名前、エントリーポイント、ライフサイクル等を設定します。

{
    "$schema": "nd/manifest.schema.json",
    "name": "PythonSampleExtension",
    "main": "main.py",
    "lifecycle": "project",
    "baseprofile": "*",
    "extensionPoints": {
    }
}

ライセンス / 免責事項

本拡張機能は、Next Designの使用許諾契約書におけるサンプルとして提供されています。サンプルに関する取り扱い、および免責事項については、Next Designの使用許諾契約書(使用許諾契約 | システム・ソフトウェア設計ツール Next Design)に準拠します。ご利用にあたっては、当該使用許諾契約書の内容をご確認ください。


  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft