Skip to main content

About How To Content

This is a reverse-reference content that explains how to use the API for the purpose of use.

About the sample code in the content

The sample code in this content is written on the assumption that it can be executed by both script and DLL extension. The code examples in the content are written on the assumption that they will be implemented by command, as shown below. First, the IApplication object is obtained from the App property of the ICommandContext object, and properties such as Workspace and Window are accessed.

public void SomeCommand(ICommandContext c, ICommandParams p) 
{
// Get the project file path
var projectFilePath = c.App.Workspace.CurrentProject.ModelUnit.AbsolutePath;
c.App.Output.WriteLine("sample",projectFilePath);
}

Note that if you write commands or event handlers using the ExtensionPoints library, properties such as CurrentProject will exist, just like script extensions.

using NextDesign.Core; 
using NextDesign.Desktop;
using NextDesign.Desktop.ExtensionPoints;

namespace NdExtSample.Commands
{
public class SomeCommand : CommandHandlerBase
{
protected override void OnExecute(ICommandContext c, ICommandParams p)
{
// Get the project file path
var projectFilePath = CurrentProject.ModelUnit.AbsolutePath;
Output.WriteLine("sample",projectFilePath);
}
}
}