Opening a TwinCAT project from the target
File.OpenProjectFromTarget allows a TwinCAT project to be loaded directly from a running target system. The configuration is read by the target and saved locally as a project file. The target must be reachable via ADS; in other words, a route must exist.
Requirements
A route to the target system has been set up. <Local> can be used for the local system. The target folder for the project must exist.
C# sample
using EnvDTE;
using System;
Type t = Type.GetTypeFromProgID("TcXaeShell.DTE.17.0");
DTE dte = (DTE)Activator.CreateInstance(t);
dte.SuppressUI = true;
// Parameters: "RouteName SolutionFolder ProjectName"
dte.ExecuteCommand("File.OpenProjectFromTarget",
"CX-123456 C:\\Temp\\Projects MyProject");
PowerShell sample
$dte = New-Object -COMObject "TcXaeShell.DTE.17.0"
$dte.SuppressUI = $true
# Route, target folder and project name separated by spaces in one string
$dte.ExecuteCommand("File.OpenProjectFromTarget",
"CX-123456 C:\Temp\Projects MyProject")
![]() | The three parameters are passed as a single string, separated by spaces: 1. The route or NetID of the target system, for example, For standalone PLC projects, there is an optional fourth parameter for the standalone project name. |
