Showing results for 
Search instead for 
Did you mean: 

Is it possible to set a value in the "Command Signals" field of an entry on a Logic Behavior ...

Siemens Legend Siemens Legend
Siemens Legend



Is it possible to set a value in the “Connected Signals” field of an entry on a Logic Behaviour for a signal that already exists using the API?


i.e. I have an entry in a LB and would like to set the connected signals value to an existing signal in my signal list programmatically.


I would also like to do the same with an exit.


I appreciate that a signal connected manually in the Resource Logic Behaviour Editor is done by selecting a signal in the signal list, and that many signals can have the same name thus making this difficult (if not impossible) programmatically. If I created a signal programmatically, this probably wouldn’t be a program, but I need to use existing signals. If several had the same name, I wouldn’t mind if they were all wired to the same entry or exit – it would be the PS engineer’s job to ensure this doesn’t cause a problem.




You can query the LB object (TxPlcLogicBehavior) and get entries and exits from the LB.

After having the entries list (  ITxPlcLogicBehaviorentry[]) , you can set a specific exit with wanted signals.



 ITxPlcLogicBehaviorEntry[] entries = logicBehavior.Entries;

foreach(ITxPlcLogicBehaviorEntry lbEntry in entries)


    lbEntry.ConnectSignal = signal; //connect

    lbEntry.ConnectedSignals  //get the list of signals that are connected




//the same for exits

ITxPlcLogicBehaviorExit[] exits = logicBehavior.Exits;

Exits[0].ConnectSignal = signal; //connect

Exits[0].ConnectedSignals  //get the list of signals that are connected


Regarding multiple signals with the same name, technically it is possible, although not recommended.

To get the signals you can use the following code and make a query on the signals list to get the signals with the specific name:


TxPlcProgram plcProgram = TxApplication.ActiveDocument.PlcProgramRoot.CurrentPlcProgram;

TxTypeFilter signalfilter = new TxTypeFilter(typeof(ITxPlcSignal));

TxObjectList signals = plcProgram.GetSignals(signalfilter);