How to create a PLC project
A new PLC project is created on the PLC node TIPC via CreateChild. You can use either a standard template or your own .plcproj template file.
Requirements
- A TwinCAT solution is open
C# sample
ITcSmTreeItem plcNode = sysManager.LookupTreeItem("TIPC");
// Simple: use standard template
ITcSmTreeItem plcProject = plcNode.CreateChild("PLC1", 0, "", "Standard PLC Template");
// Explicit path — named form (object[]):
object[] vInfoNamed = new object[] {
new string[] { "path", @"C:\tmp\Template.plcproj" },
new string[] { "pathType", "template" } // "template" or "existing"
};
ITcSmTreeItem plcProjectFromTemplate = plcNode.CreateChild("NewPlcFromTmplt", 0, "", vInfoNamed);
// Explicit path — positional form (string[]):
string[] vInfoPositional = new string[] { @"C:\tmp\ExistingProject.plcproj", "existing" };
ITcSmTreeItem plcExisting = plcNode.CreateChild("ExistingPLC", 0, "", vInfoPositional);
PowerShell sample
$plcNode = $sysManager.LookupTreeItem("TIPC")
# Standard template
$plcProject = $plcNode.CreateChild("PLC1", 0, "", "Standard PLC Template")
![]() | The |
Standard template paths
TwinCAT includes two standard templates. Both are represented by a template file in the TwinCAT directory.
Up to TwinCAT 3.1 4024
Template name | Template file |
|---|---|
Standard PLC template |
|
Empty PLC template |
|
From TwinCAT 4026
Template name | Template file |
|---|---|
Standard PLC template |
|
Empty PLC template |
|
![]() | For standard Beckhoff PLC templates, only the template name should be used, e.g., |
Access to the nested project and the project instance
TwinCAT PLC projects consist of two areas: the nested project and the project instance. The nested project has Tree Item SubType 56 and contains the source code of the PLC program, while the project instance contains the declared input and output variables of the PLC program. Accessing both areas requires different methods.
C#:
ITcSmTreeItem plcProject = sysManager.LookupTreeItem("TIPC^PLC1");
ITcProjectRoot projectRoot = (ITcProjectRoot)plcProject;
ITcSmTreeItem nestedProject = projectRoot.NestedProject;
ITcSmTreeItem projectInstance = plcProject.childitems[1];PowerShell:
$plcProject = $sysManager.LookupTreeItem("TIPC^PLC1")
$nestedProject = $plcProject.NestedProject
$projectInstance = $plcProject.childitems.item(1)![]() | TwinCAT 3.1 Build 4018 or later is required to access the |
After creating the PLC project, it can be further edited by converting it to the ITcPlcIECProject interface, which offers additional functions and access to project-specific attributes:
C#:
ITcSmTreeItem plcProject = sysManager.LookupTreeItem("TIPC^NameOfProject^NameOfProject Project");
ITcPlcIECProject iecProject = (ITcPlcIECProject) plcProject;PowerShell:
$plcProject = $systemManager.LookupTreeItem("TIPC^NameOfProject^NameOfProject Project")