Samples | PLC To use commands such as ResetOriginCmd , you must first run LoginCmd . The procedure is the same as in TwinCAT XAE. Setting boot project options This code sample sets boot project options for a PLC project using the ITcPlcProject interface. C#: ITcSmTreeItem plcProjectRoot = systemManager.LookupTreeItem("TIPC^PlcGenerated"); ITcPlcProject plcProjectRootIec = (ITcPlcProject) plcProjectRoot; plcProjectRootIec.BootProjectAutostart = true; plcProjectRootIec.GenerateBootProject(true); PowerShell:
$plcProject = $systemManager.LookupTreeItem("TIPC^PlcGenerated") $plcProject.BootProjectAutostart = $true $plcProject.GenerateBootProject($true) Saving a project and/or solution as an archive To save the entire TwinCAT solution as a ZIP-compatible archive ( *.tszip ), use the ITcSysManager9 interface. C#: ITcSysManager9 newSysMan = (ITcSysManager9)systemManager; newSysMan.SaveAsArchive(@"C:\test.tszip"); PowerShell: $systemManager.SaveAsArchive("C:\test.tszip") To reload a saved TSZIP file, use AddFromTemplate() . C#: dte.Solution.AddFromTemplate("C:\test.tszip", @"C:\tmp", "CreatedFromTemplate"); PowerShell:
$dte.Solution.AddFromTemplate("C:\test.tszip", "C:\tmp", "CreatedFromTemplate") To save a single PLC project as an archive ( *.tpzip ), use ITcSmTreeItem::ExportChild() . C#: ITcSmTreeItem plc = sysManager.LookupTreeItem("TIPC"); plc.ExportChild("PlcProject", @"C:\PlcTemplate.tpzip"); PowerShell: $plc = $systemManager.LookupTreeItem("TIPC") $plc.ExportChild("PlcProject", "C:\PlcTemplate.tpzip") CreateChild() is used to load a saved TPZIP file. C#: plcConfig.CreateChild("PlcFromTemplate", 0, null, @"C:\PlcTemplate.tpzip"); PowerShell:
$plc.CreateChild("plcFromTemplate", 0, $null, "C:\PlcTemplate.tpzip") 6.5.14 Managing PLC libraries and placeholders | Managing PLC libraries and placeholders This chapter explains how to access and manage PLC libraries and PLC placeholders. Topics: general information on PLC libraries and placeholders navigating through references TE1000 241 Version: 1.7.0