Using Custom Templates and Sample Projects to Develop LabVIEW Projects

Updated Sep 7, 2020

Environment

Software

  • LabVIEW

When you create a project, LabVIEW displays the Create Project dialog box to help you select a template or sample project you can use as a starting point. If you want to use projects you create as custom templates and sample projects, you must add source files and meta data for each project to the corresponding LabVIEW directories. Then, users can use the custom projects as starting points to develop their projects. In addition to this document, refer to the \ProjectTemplates directory to see how source files, meta data, and category overrides are stored for existing templates and sample projects. Use these files as examples of how to create and store files for custom templates and sample projects.

Selecting a LabVIEW Directory to Store Custom Content

LabVIEW searches for content to display in the Create Project dialog box in two locations. Select the location that best suits how you want to use the custom content:

  • <LabVIEW>\ProjectTemplatesUse this location if a managed code utility with version management, such the VI Package Manager, installs the custom content.

  • <LabVIEW Data>\ProjectTemplates—Use this location if you do not have write access to the <LabVIEW> directory, or if you want to single-source the custom content for multiple LabVIEW versions.

Note: LabVIEW performs a version check on all templates and sample projects in the <LabVIEW Data>\ProjectTemplates directory. If the .lvproj file for a project is saved in a later version of LabVIEW than the version currently running, the project is omitted from the Create Project dialog box.
 

Organizing the <LabVIEW Data> Directory

When you add templates and sample projects to the <LabVIEW Data> directory for the first time, you must create subdirectories to ensure that LabVIEW can find the content.

Complete the following steps to organize the <LabVIEW Data> directory:

  1. Create the ProjectTemplates directory under <LabVIEW Data>.

  2. Match the file hierarchy of the <LabVIEW>\ProjectTemplates directory such that the following paths exist:

  • <LabVIEW Data>\ProjectTemplates\CategoryOverrides

  • <LabVIEW Data>\ProjectTemplates\MetaData

  • <LabVIEW Data>\ProjectTemplates\Source
     

Storing Source Files

Source files consist of the .lvproj file, libraries, VIs, and support files, such as images and documentation, for each custom template and sample project.

Create a subdirectory in the ProjectTemplates\Source directory for each project you want to display in the Create Project dialog box and add the source files for each project to their respective subdirectories. Ensure that no subdirectory contains source files for multiple projects.

Notes:

  • Ensure that your custom templates and sample projects do not contain any auto-populating folders.

  • Ensure that your custom templates and sample projects do not contain any source VIs that are password-protected.

  • Make sure that all the files referenced in your source .lvproj are included in their respective subdirectories. Missing project files can cause problems when developers attempt to use the Create Project dialog box to create an instance of your template or sample project.

Creating and Storing Meta Data

Meta data defines the content that appears in the Create Project dialog box. LabVIEW recognizes meta data in XML format. An XML file can contain meta data for one or more projects.

Complete the following steps to create and store meta data for custom projects:

  1. Create an XML file and add the <MetaData> tag. This tag encloses all meta data.

  2. Add a <ProjectTemplate> tag for each project you want to display in the Create Project dialog box. This tag encloses meta data for each project.

  3. Use the following tags to define each template or sample project. The Example Project column of the table lists projects that use each XML tag. Refer to the file located at <LabVIEW>\ProjectTemplates\MetaData\NILV_Core_TemplateMetaData.xml to see how the meta data for existing templates and sample projects is defined.

 

XML Tag

Description

Example Project

Required Tags

<Title>

Defines the title of the project as it appears in the Create Project dialog box.

All projects

<Description>

Defines the description of the project as it appears in the Create Project dialog box.

All projects

<Filters>

Determines filters for the project, which allow users to filter items in the Create Project dialog box by category. Use a colon to separate categories and a semicolon to separate multiple filters.

All projects

<LocationPath>

Specifies the path to the directory that contains source files for the project. Use a forward slash (/) as the path separator.

This path is relative to the ProjectTemplates\Source directory. All other paths in the meta data for the project are relative to the path you provide in the <LocationPath> tag.

All projects

<ListboxImagePath>

Specifies the path to the image you want LabVIEW to display beside the project title in the Create Project dialog box. Ensure that the dimensions of the image are 32x32 pixels.

All projects

<ProjectPath>

Specifies the path to the .lvproj file for the project. If you set the value of the <CustomVIMode> to AfterPage1, this tag is optional.

Simple State Machine

Optional Tags

<Keywords>

Determines which keywords users can enter in the Additional Search box of the Create Project dialog box to search for the project. Use semicolons to separate keywords.

All projects

<DocumentationPath>

Specifies the path to the HTML file you create to provide help for the project. If you use this tag, the project displays a More Information link after the description, which links to the HTML document.

Simple State Machine

<CustomVIMode>

Determines when to run a custom VI during the project creation process. Select from the following values:

  • None—No custom VI runs. If you omit the <CustomVIMode> tag, None is the default value.

  • AfterPage1—After the user selects a project, the Create Project dialog box closes, and the custom VI runs.

  • AfterPage2NoUI—After the second page of the Create Project dialog box creates the project, the custom VI runs and completes. Then, the Create Project dialog box closes.

  • AfterPage2WithUI—After the Create Project dialog box creates the project, the Create Project dialog box closes, and the custom VI runs. The custom VI is responsible for showing or hiding its panel.

Simple State Machine, Blank VI, Actor Framework

<CustomVIPath>

Specifies the path to the custom VI you want to run during the project creation process. If you set the <CustomVIMode> tag to None, LabVIEW ignores the <CustomVIPath> tag.

Note: For the Create Project dialog to call the custom VI, you must match the connector pane of the custom VI to the connector pane of the PostCopyScripting.vi in the labview\ProjectTemplates\Source\Core\Actor Framework\scripting\TwoTasksMetaDataObj directory.

Actor Framework

<SortPriority>

Determines the order of the project in the project list of the Create Project dialog box.

The value of this tag is an index number, so a value of 0 places the project at the top of the list. If multiple items have the same priority value, LabVIEW sorts them alphabetically.

All projects

<MetaDataClass>

Specifies the path to a class that defines custom behavior for the user interface of the second page of the Create Project dialog box.

Actor Framework

<HidePrefix>

Determines whether to hide the File Prefix control on the second page of the Create Project dialog box. The default value is FALSE.

Feedback Evaporative Cooler

<HideIconOverlay>

Determines whether to hide the icon overlay controls on the second page of the Create Project dialog box. The default value is FALSE.

Feedback Evaporative Cooler

 
  1. Store the XML file in the ProjectTemplates\MetaData directory.
     

Overriding the Sorting Order for Filters

The left pane of the first page of the Create Project dialog box lists all the filters you specify in the meta data XML file. By default, LabVIEW lists filters you create in alphabetical order.

Complete the following steps to override the default sorting order for the filter list:

  1. Create an XML file and add the <CategoryOverrides> tag. This tag encloses all category override data.

  2. Add a <Category> tag for each filter for which you want to specify custom sorting behavior. This tag encloses the name and sorting priority of each filter.

  3. For each filter, create a <Name> tag and set the value to the name of the filter you used in the meta data XML file.

  4. For each filter, create a <Priority> tag and set the value according to the behavior you want.

    The value of this tag is an index number, so a value of 0 places the filter at the top of the list. Any parent filter for which you specify a value less than 100 appears above the default parent filters, such as Templates and Sample Projects. If you specify a value for any child filter, the filter appears above the default child filters, such as Desktop.

  5. Store the XML file in the ProjectTemplates\CategoryOverrides directory.