Samples | System using EnvDTE; // Load entire solution from .tnzip ITcArchivePersist persist = (ITcArchivePersist)dte.GetObject("TcArchivePersist"); // Second parameter: target folder (empty = default folder) persist.LoadFromArchive(@"C:\Archives\MyProject.tnzip", @"C:\Projects\Restored"); Importing subprojects // Import PLC from .tpzip ITcSmTreeItem plc = sysManager.LookupTreeItem("TIPC"); plc.ImportChild(@"C:\Archives\PLC1.tpzip", "", false, ""); // Import POUs from .zip ITcSmTreeItem pous = sysManager.LookupTreeItem("TIPC^PLC1^PLC1 Project"); pous.ImportChild(@"C:\Archives\POUs.zip", "", false, ""); Individual subprojects are imported via ImportChild onto the higher-level Tree Item.
The first parameter is the path to the archive file. 6.3.9 Enabling and disabling an Independent Project File | Enabling and disabling an Independent Project File The Independent Project File option saves a configuration element in its own .xti file instead of in the central .tsproj file. This simplifies version management because changes to individual elements can be tracked in separate files. This property is controlled via ITcSmTreeItem6.SaveInOwnFile . The interface must be obtained from the Tree Item using a cast. After setting the property, you must save the project so that the .xti file is created. 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 containing at least one configuration element is open. C# sample // SaveInOwnFile corresponds to the "Independent Project File" option in XAE ITcSmTreeItem6 item = (ITcSmTreeItem6)sysManager.LookupTreeItem("TIID^Device 1 (EtherCAT)"); if (!item.SaveInOwnFile) item.SaveInOwnFile = true; // To deactivate:
// item.SaveInOwnFile = false; sysManager.SaveProject(); PowerShell sample $etherCatMaster = $systemManager.LookupTreeItem("TIID^Device 1 (EtherCAT)") if ($etherCatMaster.SaveInOwnFile -eq $false) { $etherCatMaster.SaveInOwnFile = $true } SaveInOwnFile corresponds to the “Independent Project File” checkbox in TwinCAT XAE. The property is available via ITcSmTreeItem6 and requires an explicit cast. TE1000 210 Version: 1.7.0