Samples | PLC 6.5.9 Configure TMC and TPY file creation | Configure TMC and TPY file creation TwinCAT can automatically generate .tmc and .tpy files during the build process. The TMC file (TwinCAT module class) contains the type description of the PLC project and is required for TcCOM modules and the module description in the TwinCAT environment. The TPY file contains the process image of the PLC project and allows variables to be imported into other projects. Both settings are configured in the PLC project root via ConsumeXml . In addition, the process image of an existing TMC file can be imported into the I/O configuration tree as a PLC instance.
Requirements TwinCAT XAE is installed and started. A DTE connection to the target instance is active. ITcSysManager is initialized in an STA thread. A PLC project is included in the solution. Enabling TMC and TPY generation The setting is configured in the PLC project root using a short XML fragment via ConsumeXml . For TmcFileCopy and TpyFileCopy , a single request is sufficient in each case.
ITcSmTreeItem plcProjectRoot = sysManager.LookupTreeItem(@"TIPC^PLC1^PLC1 Project"); // Generate TMC file on build plcProjectRoot.ConsumeXml( " true "); // Generate TPY file on build (implicitly activates TmcFileCopy as well) plcProjectRoot.ConsumeXml( " true "); Importing a process image from a TMC file An existing TMC file can be imported into the I/O configuration tree as a PLC instance. The path to the TMC file is passed to CreateChild as the fourth parameter.
ITcSmTreeItem plcNode = sysManager.LookupTreeItem("TIPC"); // Create PLC instance from TMC file plcNode.CreateChild("ImportedPLC", 0, "", @"C:\Projects\MyModule.tmc"); By default, the generated TMC and TPY files are saved in the project folder. 6.5.10 Setting the documentation format for a PLC project | Setting the documentation format for a PLC project The documentation format of a PLC project determines which output format is used when generating the project documentation. The only supported value is TcDocGen . The format is set via ConsumeXml on the PLC project Tree Item. This feature is available starting with TwinCAT Build 4026.7. Requirements TwinCAT XAE is installed and started.
A DTE connection to the target instance is active. ITcSysManager is initialized in an STA thread. A PLC project is included in the solution. TE1000 236 Version: 1.7.0