API to add/remove nodes¶
Introduction
The APIs described below add/remove objects in a C# collection. They are used to add/remove OPC UA nodes children of the node on which they are invoked. They are supplied by the Children
generic collection, but for simplicity they can also be invoked directly on any IUANode
object.
IUANode.Add(child)¶
Adds a project node corresponding to the C# object passed as argument.
void Add(IUANode child);
Arguments
child
IUANode
C# object corresponding to the project node to add.
Example
Below is an example in which a label MyLabel child of the Panel object is added in the project:
var newPanel = InformationModel.MakeObject<Panel>("Panel");
var newLabel = InformationModel.MakeObject<Label>("MyLabel");
newPanel.Add(newLabel);
IUANode.Remove(child)¶
Removes a project node corresponding to the C# object passed as argument.
void Remove(IUANode child);
Arguments
child
IUANode
C# object corresponding to the project node to remove.
Example
Below is an example in which a label MyLabel child of the Panel1 object is removed in the project:
var myPanel = Project.Current.FindObject("Panel1");
var objToRemove = Project.Current.FindObject("MyLabel");
myPanel.Remove(objToRemove);