Creating a project - TIAPortal

TIA Portal Openness: API for automation of engineering workflows

ft:publication_title
TIA Portal Openness: API for automation of engineering workflows
Product
TIAPortal
Version
V21
Publication date
03/2026
Language
en-US
Creating a project

Requirement

Introduction

Projects can be created via TIA Portal Openness API

  • by calling the Create method on ProjectComposition

  • by calling the Create method on IEngineeringComposition

ProjectComposition.Create

Modify the following program code:

Copies the following program code to clipboard.

private static void ProjectCreate()

{

    TiaPortal tiaPortal = new TiaPortal();

    ProjectComposition projectComposition = tiaPortal.Projects;

    DirectoryInfo targetDirectory = new DirectoryInfo(@"D:\TiaProjects");

    // Create a project with name MyProject

    Project project = projectComposition.Create(targetDirectory, "MyProject");

}

According to this example

  • a folder "D:\TiaProjects\MyProject" will be created.

  • a project file "D:\TiaProjects\MyProject\MyProject.aPXX" will be created.

Note

About parameter targetDirectory

The parameter targetDirectory can also represent an UNC (Universal Naming Convention) path, therefore a project can also be created on a network shared drive.

IEngineeringComposition.Create

Modify the following program code:

Copies the following program code to clipboard.

public struct ProjectCreateParameters

{

   public DirectoryInfo TargetDirectory;

   public string Name;

   public string Author;

   public string Comment;

}

private static Project ProjectAttributeCreate(ProjectCreateParameters parameters)

{

   try

   {

    TiaPortal tiaPortal = new TiaPortal();

    ProjectComposition projectComposition = tiaPortal.Projects;

    // Prepare the create parameters

    var createParameters = new List<KeyValuePair<string, object>>

    {

    new KeyValuePair<string, object>("TargetDirectory", parameters.TargetDirectory), // Mandatory

    new KeyValuePair<string, object>("Name", parameters.Name) // Mandatory

    };

    if (!string.IsNullOrEmpty(parameters.Author))

    {

    createParameters.Add(new KeyValuePair<string, object>("Author", parameters.Author)); // Optional

    if (!string.IsNullOrEmpty(parameters .Comment))

    {

    createParameters.Add(new KeyValuePair<string, object>("Comment", parameters.Comment)); // Optional

    }

    // Create a project with both mandatory and optional parameters

    return ((IEngineeringComposition)projectComposition) .Create(typeof(Project), createParameters) as Project;

    }

   catch (Exception ex)

   {

    Console.WriteLine($"Exception of type {ex.GetType()} occurred: {ex.Message}");

    return null;

   }

}

According to this example:

  • a folder "D:\TiaProjects\MyProject" will be created.

  • a project file "D:\TiaProjects\MyProject\MyProject.aPXX" will be created with project attributes Author as "Bob" and Comment as "This project was created with openness".

Parameters for creating project with optional project attributes

Parameter

Data Type

Is Mandatory

Description

Author

String

No

Author of a project.

Comment

String

No

Comment for the project.

Name

String

Yes

Name of a project,

TargetDirectory

DirectoryInfo

Yes

Directory that will contain the created proeject folder.