What are Extensions?
Next Design allows users to freely extend functionality by utilizing APIs provided by Next Design from programming languages. These individual functions are called extensions. By developing Next Design extensions, the following additional functions can be realized:
- Validation functions can be implemented to verify the integrity of designed models and to present errors and warnings.
- Custom import/export functions can be developed, such as importing from existing asset documents, generating simulation data, and outputting documents in custom formats.
- Toolchains can be realized through data linkage with external tools.
Features
Next Design extensions have the following features:
Development with Scripts and DLLs
Extensions can be developed using C# and Python. C# is a sophisticated language, and in recent years, it has become more open-source, allowing it to run on Linux/Mac and mobile devices. There are two methods for implementing extensions, and you can choose the method for each extension:
- Implementation method: Compiling from C# to a .NET DLL (recommended)
- Implementation method: Using scripts (C# script/Python script)
Next Design's C# scripts are dynamically compiled at runtime, resulting in very fast performance. However, DLL development offers a richer library, and considering ease of debugging and maintainability, DLL development is recommended. The .NET DLL method allows for advanced feature extensions such as event handling and UI enhancements.
Development using Python scripts allows for the implementation of command and event handlers, similar to C# scripts.
For more details, please refer to Scripts and DLLs.
- C#
- Python
//Command Handler
public void SayHello(ICommandContext context, ICommandParams commandParams)
{
App.Window.UI.ShowInformationDialog("Hello !", "Hello World");
}
from nd.desktop import *
def say_hello(context: ICommandContext, commandParams: ICommandParams):
context.App.Window.UI.ShowInformationDialog("Hello !", "Hello World")
Extension Points
Extension points are UI elements and events that are extended by extensions. This file is called the manifest file (hereafter referred to simply as "manifest").
Extension points are defined in JSON as follows:
title="manifest.json"
"extensionPoints": {
"commands": [
{
"id": "Command.SayHello",
"execFunc": "SayHello"
}
],
...
}
-
Functionality can be extended by adding buttons, etc., to the ribbon (menu).
-
Functionality can be extended by receiving events such as model editing operations and file operations and using those events.
-
The definitions of the ribbon and events extended by the extension are read from the manifest written for each extension.
Extension Lifecycle
Extensions can be enabled at the same time as application startup, or depending on the project profile.
Also, multiple extensions can be enabled for a single profile.
API Operations
Through the Next Design API, you can access various information about your application and manipulate the user interface. For example, the following operations are possible:
title="Example of API Call"`
//Open the project file
var filePath = "xxx.nproj";
Workspace.OpenProject(filePath);
//Get all elements of the project
var project = CurrentProject;
var children = project.GetAllChildren();
//Output the names of descendant elements to the Output tab of the Info window
foreach ( var child in children )
{
Output.WriteLine("sample",child.Name);
}
//Activate the Output tab of the Info window
Window.ActiveInfoWindow = "Output";
Window.CurrentOutputCategory = "sample";
- Open, create, and save projects.
- Get and change the selected model in the application.
- Access model information to add or update models.
- By validating the model and setting error information for each model, messages are displayed at the error locations.
Multilingual Support
- A multilingual support mechanism is provided that allows the extension's display language to be switched in conjunction with the display language switching option in Next Design.
{
"locale": "ja",
"resourceStrings" : {
"MyExt.Tab.Label": "Extension",
"MyExt.ValidationGroup.Label": "Model Validation",
"MyExt.ValidationButton.Label": "Validation",
"MyExt.ValidationButton.Description": "Validates all models.",
"MyExt.Error.CanNotBeEmpty.Title": "Cannot be empty",
"MyExt.Error.CanNotBeEmpty.Message": "Name field cannot be empty",
"MyExt.Error.CanNotChange.Message2": "{0} cannot be {1}"
}
}