前回に引き続き、 Fusion 360 のユーザ インタフェースについて、API の視点から解説していきたいと思います。今回 Workspace(ワークスペース)と、関連ずけられているメニューを重点的にご案内します。

Fusion 360 では、モデリング画面上部のツールバー左端のボタンを選択することで、各フェーズに必要なユーザインタフェースの表示を切り替えます。この単位が Workspace で、それぞれ、表示されるツールが異なります。下記は、その例です。



Fusion 360 API では、各 Workspace は Workspaces コレクションに格納される Workspace オブジェクトとして扱われています。また、他のユーザ インタフェース要素と同様に、それぞれ ID で識別されていて、次の JavaScript コード(Script 実装)で Fusion 360 が定義している Workspace を列挙することが出来ます。
//Author-//Description-/*globals adsk*/(function () { “use strict”; if (adsk.debug === true) { /*jslint debug: true*/ debugger; /*jslint debug: false*/ } try { var app = adsk.core.Application.get(); var ui = app.userInterface; var workspace = null; var workspaces = ui.workspaces; var maxnum = workspaces.count; for (var index = 0; index < maxnum; index++) { workspace = workspaces.item(index); console.log(workspace.name + " Workspace >> " + workspace.id); } } catch (e) { if (ui) { ui.messageBox('Failed : ' + (e.description ? e.description : e)); } } adsk.terminate();}());
このコードを実行すると、すべての Workspace を Web ブラウザのコンソール画面に表示します(Debug モードで実行)。Fusion 360 が内部的に保持していて、現在のバージョンでは表示されないものも存在している点に注意してください。
Sculpt Workspace >> TSplineEnvironment
Model Workspace >> FusionSolidEnvironment
Patch Workspace >> FusionSurfaceEnvironment
Render Workspace >> FusionRenderEnvironment
Animation Workspace >> Publisher3DEnvironment
CAM Workspace >> CAMEnvironment
Debug Workspace >> DebugEnvironment
Modeling Workspace >> FusionModelingEnvironment
Assemble Workspace >> FusionAssembleEnvironment
Visualization Workspace >> FusionVisualizationEnvironment
Modeling Workspace >> CAMModelingEnvironment
Documentation Workspace >> FusionDocumentationEnvironment
次に、Workspace に関連付けられているツールバーパネルとパネル内に配置されたコマンドの一覧を取得してみます。ここでは、Render ワークスペースをアクティブな状態にして次のコードを実行してみます。
//Author-//Description-/*globals adsk*/(function () { “use strict”; if (adsk.debug === true) { /*jslint debug: true*/ debugger; /*jslint debug: false*/ } try { var app = adsk.core.Application.get(); var ui = app.userInterface; var toolBarPanel = null; var control = null; var currentWorkspace = ui.activeWorkspace; console.log(“—————– ” + currentWorkspace.name + ” Workspace”); for(var index = 0 ; index<currentWorkspace.toolbarPanels.count ; index++){ toolBarPanel = currentWorkspace.toolbarPanels.item(index); if (toolBarPanel.isVisible){ console.log(toolBarPanel.name); for(var index2 = 0 ; index2<toolBarPanel.controls.count ; index2++){ control = toolBarPanel.controls.item(index2); console.log(” > ” + control.id); } } } } catch (e) { if (ui) { ui.messageBox(‘Failed : ‘ + (e.description ? e.description : e)); } } adsk.terminate();}());
Web ブラウザのコンソール画面には、このように ID を表示するはずです。先に示した Render ワークスペースのスクリーンショットと見比べてみてください。PhysicalMaterialCommand の ID を持つコマンドは、折りたたまれたパネル内に配置されています。
—————– Render Workspace
SETUP
> PhysicalMaterialCommand
> AppearanceCommand
> RenderingEnvCmd
> CameraSettingsCommand
> FusionAddEditDecalCommand
RENDER
> ShowRapidRTUICmd
> SaveAsImageCommand
> A360RenderCommand
簡単な走査方法ですが、これらを理解することで、Fusion 360 上の Workspace、ToolBarPanel とパネル内のコマンド(ToolbarControl オブジェクト)の関係を理解いただけるものと思います。
By Toshiaki Isezaki

You must be logged in to post a comment.