Wednesday, 28 January 2015

Metasequoia 4 Plugins – part 5

We can create a project template to generate an empty Metasequoia plugin project with most of the project properties already set.

Once we have created the project template we can select it from the list of templates in the File>Add>New Project dialog.

This means we won’t have to set all the project’s properties manually every time we create a new plugin.

Rather than create one template for all plugin categories as I do here you could make a separate template for each plugin category.

First we need to make a new plugin project that has all the settings we wish to save in the template.

With the mqsdk solution open in Visual Studio and selected in the Solution Explorer window add a new Visual C++ Win32 project.

I used spaces in the project name here but it is better if you do not have spaces in the name. The space caused an error for the Post-Build Event command.

Add new project to solution

Choose DLL and Empty project in Application Settings.

Choose DLL and Empty project

Set the project’s properties in the Property Pages the same as in previous posts.

Remember to click OK or Apply to save the changes.

Use the Using Visual Studio instructions in the mqsdk_en.html document to create Debug and Release configurations for 64 bit Windows if required.

Create 64 bit configuration

For All Configurations and All Platforms set Configuration Properties>General>Output Directory to “$(Platform)\$(Configuration)\”.

For All Configurations and All Platforms the Configuration Properties>General>Intermediate Directory to “$(Platform)\$(Configuration)\obj\”.

For All Configurations and All Platforms set Configuration Properties>General>Character Set to “Multi-Byte Character Set”.

Set General properties for all platforms

For All Configurations and All Platforms set Configuration Properties>C/C++>General > Additional Include Directories to “..” so Visual Studio will search the project’s parent directory for any SDK header files it needs for the project.

Set Additional Include directories

For Debug Configuration and All Platforms set Configuration Properties>Debugging> Command to the path to Metaseq.exe.

Unfortunately I found that this setting is not saved in the template and will have to be set for each project created using the template.

Set path to metaseq exe

For Debug Configuration and All Platforms use Command Prompt commands and Macros to set Configuration Properties>Build Events>Post-Build Event>Command Line to copy the output *.dll to the appropriate folder in Metasequoia\Plugins\.

This project property will need to be changed manually to match each type of plugin we create. If we create a wizard for the template we may be able to set this property from user input.

If creating separate templates for each plugin category the correct folder can be set for each.

Set Post-Build event

Add a new blank *.cpp file to the project and name it “myplugin.cpp”.

Add new cpp file

Add MQInit.cpp located in the project’s parent directory to the project.

Add MQInit cpp

Open myplugin.cpp in the editor and type in the following code which includes all the functions necessary for all categories of plugin.

Replace any information like the author name and Product (author) number to your personal details.

Save all if you haven’t already and click File>Export Template to run the Export Template Wizard.
Select Project Template and select the project in the drop down list.

Run the export Template Wizard

Name the template, add a description and icon and preview images if you wish.

Uncheck the option to automatically import into Visual Studio but do check the option to open the exported template folder in File Explorer.

Template Options

Navigate to your custom project template folder which by default is, C:\Users\<username> \Documents\Visual Studio 2013\Templates\ProjectTemplates\.

Create a new folder named “Metasequoia Plugin” inside the Visual C++ Project folder.

Copy to the Visual C   Projects custom template folder

Copy the zip file containing the exported project template into the “Metasequoia Plugin” folder you created.

The template now appears in the template list and can be used as a starting point for a new plugin project.

Project template in Add New Project dialog

prev | next | first

No comments:

Post a Comment