Configuration | Basics void CSysManDialog::IterateCollection(TCatSysManagerLib::ITcSmTreeItemPtr parentPtr) { IEnumVARIANTPtr spEnum = parentPtr->_NewEnum; ULONG nReturned = 0; VARIANT variant[1] = {0}; HRESULT hr = E_UNEXPECTED; do { hr = spEnum->Next(1, &variant[0], &nReturned); if(FAILED(hr)) break; for(ULONG i = 0; i { IDispatchPtr dispatchPtr; IDispatch* pDispatch; TCatSysManagerLib::ITcSmTreeItemPtr childPtr; HRESULT hr; if(variant[0].vt == VT_DISPATCH) { TCatSysManagerLib::ITcSmTreeItem* pChild = 0; dispatchPtr.Attach((variant[0].pdispVal)); hr = dispatchPtr.QueryInterface(__uuidof(TCatSysManagerLib::ITcSmTreeItem), reinterpret_cast(&pChild)); childPtr.Attach(pChild); _bstr_t strName = pChild->GetName(); } } } while(hr != S_FALSE); // S_FALSE zeigt Ende der Sammlung an } Sample (PowerShell):
$systemItem = $systemManager.LookupTreeItem("TIRC") foreach($child in $systemItem) { write-host$child.Name } Browsing Main Tree Items (Filtered) For browsing only the main childs of the current tree item use the ITcSmTreeItem::ChildCount and ITcSmTreeItem:Child(n) pair of properties. These methods only work on the direct childs (non-recursive). Browsing Variables / Symbols only To Browse the Variables / Symbols use the ITcSmTreeItem::VarCount(x) , ITcSmTreeItem::Var(x,n) pair of properties. A selection of the variable type (input variables or output variables) can be done by parameter.
4.2.3 Custom TreeItem Parameters | Custom TreeItem Parameters The ITcSmTreeItem interface is supported by every TwinCAT tree item and has a very generic character. To support the specification of all the devices, boxes and terminals, together with many other different types of tree items, all custom parameters of a tree item are accessible via the XML representation of the tree item. This XML-String can be accessed by the method ITcSmTreeItem::ProduceXml and its counterpart ITcSmTreeItem::ConsumeXml. This function pair has the same functionality as the "Export XML Description ..." and "Import XML Description ..." commands from the main menu of the TwinCAT IDE (see snapshot below).
TE1000 27 Version: 1.7.0