Samples | System 6.3.7 Saving a TwinCAT project as an archive | Saving a TwinCAT project as an archive TwinCAT supports two types of project export: The entire solution can be saved as a .tnzip archive. ExportChild exports individual subprojects – such as a PLC project or a POUs folder – as a .tpzip or .zip file. Requirements TwinCAT XAE is installed and started. A DTE connection to the target instance is active. ITcSysManager is initialized in an STA thread. A TwinCAT solution is open. The target directory for the archive exists. Saving a solution as an archive The ITcArchivePersist interface is available via dte.GetObject("TcArchivePersist") .
SaveAsArchive saves the entire solution as a .tnzip file. The archive contains all project files and can be restored on another computer. using EnvDTE; // Get ITcArchivePersist object via DTE ITcArchivePersist persist = (ITcArchivePersist)dte.GetObject("TcArchivePersist"); // Save solution as .tnzip persist.SaveAsArchive(@"C:\Archives\MyProject.tnzip"); // Optionally close solution afterwards dte.Solution.Close(); Exporting subprojects ExportChild , available at ITcSmTreeItem , can be used to export individual subprojects. The first parameter specifies the name of the child element to be exported, and the second specifies the target file path.
// Export PLC project as .tpzip ITcSmTreeItem plc = sysManager.LookupTreeItem("TIPC"); plc.ExportChild("PLC1", @"C:\Archives\PLC1.tpzip"); // Export POUs as .zip ITcSmTreeItem pous = sysManager.LookupTreeItem("TIPC^PLC1^PLC1 Project^POUs"); pous.ExportChild("", @"C:\Archives\POUs.zip"); 6.3.8 Loading a TwinCAT project from an archive | Loading a TwinCAT project from an archive TwinCAT supports two methods for importing projects: The entire solution can be restored from a .tnzip archive. Individual subprojects can be imported into a Tree Item via ImportChild . Requirements TwinCAT XAE is installed and started. A DTE connection to the target instance is active.
ITcSysManager is initialized in an STA thread. An archive file named .tnzip or .zip exists. Loading a solution from archive The ITcArchivePersist interface is available via dte.GetObject("TcArchivePersist") . LoadFromArchive restores the solution to the specified target folder. An empty path uses the default folder. TE1000 209 Version: 1.7.0