Gmsh (Language Support & 3D Interactive Preview)
The definitive Visual Studio Code extension for Gmsh. Features • Getting Started • Configuration • Snippets • 日本語ドキュメント ✨ Features1. 🧠 Comprehensive Gmsh Language Support (IntelliSense)
2. ⚡ Real-Time 3D Geometry & Mesh Preview
🚀 Getting StartedInstallationMethod 1: Visual Studio Code Marketplace (Recommended for VS Code)Search for Or install directly from your terminal:
👉 View on Visual Studio Marketplace Method 2: Open VSX Registry (Recommended for VSCodium, Gitpod, Theia)Search for
Method 3: Install from GitHub Releases (.vsix)
Method 4: Build and Install from Source
Usage
Opening the 3D PreviewChoose any of these methods:
Automatic Gmsh CLI DetectionThe extension automatically searches common system paths,
⚙️ Configuration (
|
| Setting | Type | Default | Description |
|---|---|---|---|
gmsh.executablePath |
string |
"gmsh" |
Path to the Gmsh executable (e.g., gmsh or C:\gmsh\gmsh.exe) |
gmsh.meshDimension |
number |
2 |
Default mesh dimension (0: Geometry, 1: 1D, 2: 2D, 3: 3D) |
gmsh.debounceDelay |
number |
400 |
Delay (ms) after code edits before refreshing the preview |
⌨️ Snippets & Shortcuts
Type the prefix and press Tab or Enter to expand:
| Prefix | Expands To | Description |
|---|---|---|
Point |
Point(1) = {x, y, z, lc}; |
Point primitive |
Line |
Line(1) = {start, end}; |
Line segment |
Circle |
Circle(1) = {start, center, end}; |
Circular arc |
Curve Loop |
Curve Loop(1) = {c1, c2, ...}; |
Closed curve boundary |
Plane Surface |
Plane Surface(1) = {loop1}; |
Planar surface |
Surface Loop |
Surface Loop(1) = {s1, s2, ...}; |
Enclosed surface shell |
Volume |
Volume(1) = {loop1}; |
3D Volume |
Extrude |
Extrude {dx, dy, dz} { ... }; |
Translation extrusion |
Rotate |
Rotate { {ax,ay,az}, {px,py,pz}, angle } { ... } |
Rotation transform |
Box |
Box(1) = {x, y, z, dx, dy, dz}; |
OpenCASCADE 3D box |
Cylinder |
Cylinder(1) = {x, y, z, dx, dy, dz, r}; |
OpenCASCADE cylinder |
Sphere |
Sphere(1) = {x, y, z, r}; |
OpenCASCADE sphere |
BooleanDifference |
BooleanDifference(1) = { ... } { ... }; |
OpenCASCADE Boolean cut |
MeshSize |
MeshSize {points} = size; |
Prescribed element size |
Transfinite Curve |
Transfinite Curve {curves} = n; |
Structured 1D discretization |
For |
For i In {1:10} ... EndFor |
Loop iteration |
If |
If (cond) ... EndIf |
Conditional branch |
Printf |
Printf("value: %g", var); |
Formatted console output |
🇯🇵 日本語
Gmsh のジオメトリスクリプト(.geo)およびメッシュファイル(.msh)に対応した VS Code 拡張機能です。
構文ハイライト・入力補完・スニペット・ホバー解説といった言語サポートと、Three.js を用いたリアルタイム 3D プレビュー・双方向コードジャンプを1つの拡張機能に統合しています。
- IntelliSense 補完:
Point,Circle,Extrude,MeshSize等の主要コマンドおよびファイル内で定義した変数を自動補完。 - ホバー表示: コマンドの上にマウスを置くだけで構文仕様・引数の意味・使用例を表示。
- 3D プレビュー: コード編集時にミリ秒単位で再描画。3D 上の点・線・面をクリックするとコードの該当行へ即座にジャンプ。
- 画面固定サイズのラベル表示: ズーム倍率に関わらず、点(
P1)や線(L1)のラベルが常に読みやすい一定ピクセルサイズを維持。 - 直感的なグリッド&スケール表示: モデル寸法に応じたキリの良いマス目単位(
1, 2, 5 × 10^n)を自動算出。3D 画面上・インスペクター・VS Code 最下部ステータスバーの3箇所で「1マスの長さ」を確認可能。 - Gmsh 自動検出: お使いの PC 内の
gmsh.exeを自動検出するため、環境変数の事前設定が不要です。
インストール方法(日本語)
方法 1: Visual Studio Code マーケットプレイスからインストール(推奨)
VS Code の拡張機能ビュー(Ctrl+Shift+X)で gmsh-preview または Gmsh を検索し、「インストール」をクリックします。
ターミナルから直接インストールすることも可能です:
code --install-extension Ringo3Apples.gmsh-preview
👉 Visual Studio Marketplace で見る
方法 2: Open VSX レジストリからインストール(VSCodium / Gitpod / Eclipse Theia 等)
VSCodium 等の拡張機能ビューから gmsh-preview を検索してインストール、またはターミナルから:
codium --install-extension Ringo3Apples.gmsh-preview
方法 3: GitHub Releases (.vsix) からの手動インストール
- GitHub Releases から最新の
gmsh-preview-*.vsixパッケージをダウンロードします。 - VS Code の拡張機能ビュー(
Ctrl+Shift+X)の右上「…」メニューから「VSIX からのインストール...」を選択します(またはファイルを VS Code ウィンドウへドラッグ&ドロップ)。
🛠️ Development & Building
# Clone the repository
git clone https://github.com/Ringo3apples/gmshExtension.git
cd gmshExtension
# Install dependencies
npm install
# Build the extension and Webview bundle
npm run build
# Watch mode for rapid development
npm run watch
# Type-check TypeScript
npm run compile
Press F5 in VS Code to launch the Extension Development Host window for live debugging.
📄 License
This extension is licensed under the MIT License.