How to disable/enable a tree item (e.g. an I/O device)

Requirements

To disable/enable a tree item in a configuration, an instance of the TwinCAT System Manager must be created, and the configuration has to be opened. The LookupTreeItem method of the ITcSysManager interface returns a ITcSmTreeItem interface pointer implemented by the tree item referenced by its pathname.

This interface contains a Disabled property of the tree item.

Procedure

The ProgId "TCatSysManager.TcSysManager" can be used to create an instance of the System Manager that implements the ITcSysManager interface. This interface has a LookupTreeItem method that returns a ITcSmTreeItem pointer to a specific tree item given by its pathname. To disable/enable the tree item "TIID^Device 1 (C1220)" the following vbscript code can be used:

Sample (vbscript):

dim tsm
dim item
set tsm = CreateObject("TCatSysManager.TcSysManager")
call tsm OpenConfiguration("c:\twincat\myConfig.wsm")
set item = tsm.LookupTreeItem("TIID^Device 1(C220)")
item.Disabled = SMDS_DISABLED '(or item.Disabled =SMDS_NOT_DISABLED to enable the tree item)
call tsm.SaveConfiguration

See Also

How to... section, ITcSysManager, LookupTreeItem, ITcSmTreeItem, Disabled

Built on Tuesday, Mai 01, 2001