Samples | Motion elemSetSymbol.Attributes.Append(attrSymbolName); elemSetSymbol.Attributes.Append(attrEnable); xmlDoc.DocumentElement.AppendChild(elemSetSymbol); string sConsumeXml = xmlDoc.OuterXml; stream.ConsumeXml(sConsumeXml); 6.10 Motion | Motion 6.10.1 Creating NC axes | Creating NC axes NC axes are created in a defined tree structure under the NC configuration node TINC . The set-up always follows the same pattern: First, an NC task is created; then, the axis node below the task is called. Axes can be created directly under the axis node or in a subfolder. Subfolders help organize the axes in more complex projects.
Requirements A TwinCAT solution is open and a DTE connection is active. ITcSysManager was initialized as a COM object in an STA thread. The NC/drive module is licensed and available in the solution (the TINC node is visible). Creating an NC task and axes The NC configuration node TINC is accessed via LookupTreeItem . The NC task is then created under this node. The task's axis folder can then be accessed via LookupChild("Axes") . Axes and subfolders are created using CreateChild . C#:
// Look up NC configuration and create NC task ITcSmTreeItem motion = sysManager.LookupTreeItem("TINC"); // " SAF" suffix is always appended to the name ITcSmTreeItem nc = motion.CreateChild("NC-Task", 1, null, null); ITcSmTreeItem cnc = motion.CreateChild("CNC", 400); // Look up the axes folder of the NC task ITcSmTreeItem axesFolder = nc.LookupChild("Axes"); // Create subfolder for axes (SubType -1) ITcSmTreeItem folder1 = axesFolder.CreateChild("Folder1", -1); // Create axis (SubType 1) ITcSmTreeItem axisInFolder = axesFolder.CreateChild("Axis 2", 1, "Folder1/"); PowerShell:
$ncConfig = $systemManager.LookupTreeItem("TINC") $ncConfig.CreateChild("NC-Task", 1) $axes = $systemManager.LookupTreeItem("TINC^NC-Task^Axes") $axes.CreateChild("Axis 1", 1) bstrBefore rules for NC nodes The third parameter of CreateChild is called bstrBefore and controls the position within a folder where the new element will be inserted. A trailing / in the path means “last item in the folder”. TE1000 293 Version: 1.7.0 bstrBefore Meaning "Folder1/" Insert as the last item in Folder1. "Folder1/Axis1" Insert before Axis1 in Folder1. "Folder1/Folder2/" Insert as the last item in Folder2.