Last updated on April 10, 2022
Edit UANodeSet files with Free OPC UA Modeler.
This Post is part of the OPC UA Information Model Tutorial.
Contents
Starting Free OPC UA Modeler
- Execute
///C:/WPy64-3760/WinPython Command Prompt.exe
- run the modeler for the same command prompt with
..\python-3.7.6.amd64\Scripts\opcua-modeler.exe
Free OPC UA Modeler is now up and running.

Closing Free OPC UA Modeler
Use the window’s close button [X
] to end Free OPC UA Modeler. Using menu Actions -> Quit
or Actions -> Close Model
has seemingly no effect.
Create a new model
Press Actions -> New Model
This will
- introduce the default nodeset
Opc.Ua.NodeSet2.xml
with its Namespace, Types and Objects to your model - start the
opcua.server
Import Reference Nodesets (optional)
The default nodeset contains all basic type and object definitions, which can be used to model your own nodeset. Occasionally, you may want to include models of other nodesets, which are already defined. This is the case if you want to edit UANodeSet files that depend on other models. Such nodeset will declare their dependencies in the <Models>
section, like so:
<Models> <Model ModelUri="http://br-automation.com/OpcUa/PLC/PV/" PublicationDate="2018-08-29T08:11:18Z" Version="2.00"> <RequiredModel ModelUri="http://opcfoundation.org/UA/" PublicationDate="2018-05-15T00:00:00Z" Version="1.04"/> <RequiredModel ModelUri="http://opcfoundation.org/UA/DI/" PublicationDate="2013-12-02T00:00:00Z" Version="1.01"/> <RequiredModel ModelUri="http://PLCopen.org/OpcUa/IEC61131-3/" PublicationDate="2010-03-24T00:00:00Z" Version="2.01"/> <RequiredModel ModelUri="http://br-automation.com/OpcUa/PLC/" PublicationDate="2018-01-30T00:00:00Z" Version="2.01"/> </Model> </Models>
Note: Above snippet is taken from an UANodeSet file that was generated with Automation Studio 4.7.2
To include an additional, 3rd party nodeset use Actions -> Import XML
. Alternatively, a right click
into the subwindow Node Sets will offer a pop-up menu to Add Reference Node Set
. A commonly imported nodeset is Opc.Ua.Di.NodeSet2
, which contains Device Integration Objects.
It may be received from several (equally legit) places:
- fixed version 1.2: https://opcfoundation.org/UA/schemas/DI/1.2/Opc.Ua.Di.NodeSet2.xml
- latest version: https://raw.githubusercontent.com/OPCFoundation/UA-Nodeset/master/DI/Opc.Ua.Di.NodeSet2.xml
Note: A collection of UANodeSet files is maintained by the OPC Foundation at https://github.com/OPCFoundation/UA-Nodeset
The OPC Foundation uses this repository as part of their official review process!
Note: Pay attention to the
Version
attributes of the<RequiredModel>
elements!
Download those files in their raw XML format to an arbitrary(?) folder. Then use Action -> Import XML
with that file. Free OPC UA Modeler will show
- a new namespace
http://opcfoundation.org/UA/DI/
- additional objects in
Root/Objects
Create a custom namespace for your model
OPC UA separates objects and types into different namespaces to avoid naming conflicts. In order to create your own custom types and object, create your own, custom namespace first. right click
into the subwindow NamespaceArray and select Add Namespace
Make sure the index of your custom nodeset is 1. The name/value can be selected arbitrarily, but it’s good practice to select an URL.
Note: The OPC Foundation provides relevant files and/or information at the URLs that name their namespaces. Example:
Note: The standard UA nodeset of the OPC Foundation is always indexed at 0. Custom nodeset are always indexed at 1. Many modelers support only index 1 for custom nodesets (implcitly or explicitly).

Editing a model
Following https://github.com/FreeOpcUa/opcua-modeler#creating-custom-structures I seem to be affected by https://github.com/FreeOpcUa/opcua-modeler/issues/86 (because I imported Opc.Ua.Di before).
When adding new types and objects, make sure to always use your custom namespace.
Save a model
Press the Save button. It’s advisable to git diff
now and then to verify correctness of the NodeSet.
Loading a model
Free OPC UA Modeler loses referenced NodeSets, so they have to be re-referenced whenever a model is opened.
You will notice a lost reference in the diff of the .uamodel
file.
Loading UANodeSet from B&R Automation Studio
I tried to load the UANodeSet from ECU1 of Broadpeak with Free OPC UA Modeler.
Only with the base nodeset -> fails opcua.ua.uaerrors._auto.BadParentNodeIdInvalid: The parent node id does not to refer to a valid node.(BadParentNodeIdInvalid)
uamodeler.model_manager - INFO - Starting server on opc.tcp://0.0.0.0:48400/freeopcua/uamodeler/') uamodeler.server_manager - INFO - Starting python-opcua server') opcua.server.server - WARNING - Endpoints other than open requested but private key and certificate are not set.') opcua.server.binary_server_asyncio - WARNING - Listening on 0.0.0.0:48400') uamodeler.namespace_widget - INFO - Writting namespace array: ['http://opcfoundation.org/UA/', 'http://foo.com/']') uamodeler.namespace_widget - INFO - Writting namespace array: ['http://opcfoundation.org/UA/', 'http://foo.com/zebra/flattening']') uamodeler.model_manager - INFO - Starting server on opc.tcp://0.0.0.0:48400/freeopcua/uamodeler/') uamodeler.server_manager - INFO - Starting python-opcua server') opcua.server.server - WARNING - Endpoints other than open requested but private key and certificate are not set.') opcua.server.binary_server_asyncio - WARNING - Listening on 0.0.0.0:48400') opcua.common.xmlimporter - WARNING - failure adding node NodeData(nodeid:NumericNodeId(ns=1;i=300000))') uawidgets.utils - ERROR - The parent node id does not to refer to a valid node.(BadParentNodeIdInvalid)') Traceback (most recent call last): File "C:\WPy64-3741\python-3.7.4.amd64\lib\site-packages\uawidgets\utils.py", line 21, in wrapper result = func(self, *args) File "C:\WPy64-3741\python-3.7.4.amd64\lib\site-packages\uamodeler\uamodeler.py", line 247, in open self._model_mgr.open(path) File "C:\WPy64-3741\python-3.7.4.amd64\lib\site-packages\uamodeler\model_manager.py", line 178, in open self.open_xml(path) File "C:\WPy64-3741\python-3.7.4.amd64\lib\site-packages\uamodeler\model_manager.py", line 110, in open_xml self._open_xml(path) File "C:\WPy64-3741\python-3.7.4.amd64\lib\site-packages\uamodeler\model_manager.py", line 116, in _open_xml path = self.import_xml(path) File "C:\WPy64-3741\python-3.7.4.amd64\lib\site-packages\uamodeler\model_manager.py", line 99, in import_xml new_nodes = self.server_mgr.import_xml(path) File "C:\WPy64-3741\python-3.7.4.amd64\lib\site-packages\uamodeler\server_manager.py", line 68, in import_xml return self._backend.import_xml(path) File "C:\WPy64-3741\python-3.7.4.amd64\lib\site-packages\uamodeler\server_manager.py", line 112, in import_xml return self._server.import_xml(path) File "C:\WPy64-3741\python-3.7.4.amd64\lib\site-packages\opcua\server\server.py", line 469, in import_xml return importer.import_xml(path, xmlstring) File "C:\WPy64-3741\python-3.7.4.amd64\lib\site-packages\opcua\common\xmlimporter.py", line 67, in import_xml node = self._add_node_data(nodedata) File "C:\WPy64-3741\python-3.7.4.amd64\lib\site-packages\opcua\common\xmlimporter.py", line 86, in _add_node_data node = self.add_variable(nodedata) File "C:\WPy64-3741\python-3.7.4.amd64\lib\site-packages\opcua\common\xmlimporter.py", line 221, in add_variable res[0].StatusCode.check() File "C:\WPy64-3741\python-3.7.4.amd64\lib\site-packages\opcua\ua\uatypes.py", line 233, in check raise UaStatusCodeError(self.value) opcua.ua.uaerrors._auto.BadParentNodeIdInvalid: The parent node id does not to refer to a valid node.(BadParentNodeIdInvalid) uamodeler.model_manager - INFO - Starting server on opc.tcp://0.0.0.0:48400/freeopcua/uamodeler/') uamodeler.server_manager - INFO - Starting python-opcua server') opcua.server.server - WARNING - Endpoints other than open requested but private key and certificate are not set.') opcua.server.binary_server_asyncio - WARNING - Listening on 0.0.0.0:48400') opcua.common.xmlimporter - WARNING - failure adding node NodeData(nodeid:NumericNodeId(ns=1;i=300000))') uawidgets.utils - ERROR - The parent node id does not to refer to a valid node.(BadParentNodeIdInvalid)') Traceback (most recent call last): File "C:\WPy64-3741\python-3.7.4.amd64\lib\site-packages\uawidgets\utils.py", line 21, in wrapper result = func(self, *args) File "C:\WPy64-3741\python-3.7.4.amd64\lib\site-packages\uamodeler\uamodeler.py", line 260, in import_xml self._model_mgr.import_xml(path) File "C:\WPy64-3741\python-3.7.4.amd64\lib\site-packages\uamodeler\model_manager.py", line 99, in import_xml new_nodes = self.server_mgr.import_xml(path) File "C:\WPy64-3741\python-3.7.4.amd64\lib\site-packages\uamodeler\server_manager.py", line 68, in import_xml return self._backend.import_xml(path) File "C:\WPy64-3741\python-3.7.4.amd64\lib\site-packages\uamodeler\server_manager.py", line 112, in import_xml return self._server.import_xml(path) File "C:\WPy64-3741\python-3.7.4.amd64\lib\site-packages\opcua\server\server.py", line 469, in import_xml return importer.import_xml(path, xmlstring) File "C:\WPy64-3741\python-3.7.4.amd64\lib\site-packages\opcua\common\xmlimporter.py", line 67, in import_xml node = self._add_node_data(nodedata) File "C:\WPy64-3741\python-3.7.4.amd64\lib\site-packages\opcua\common\xmlimporter.py", line 86, in _add_node_data node = self.add_variable(nodedata) File "C:\WPy64-3741\python-3.7.4.amd64\lib\site-packages\opcua\common\xmlimporter.py", line 221, in add_variable res[0].StatusCode.check() File "C:\WPy64-3741\python-3.7.4.amd64\lib\site-packages\opcua\ua\uatypes.py", line 233, in check raise UaStatusCodeError(self.value) opcua.ua.uaerrors._auto.BadParentNodeIdInvalid: The parent node id does not to refer to a valid node.(BadParentNodeIdInvalid) opcua.server.address_space - WARNING - AddNodesItem: Requested NodeId NumericNodeId(ns=1;i=100) already exists') opcua.common.xmlimporter - WARNING - failure adding node NodeData(nodeid:NumericNodeId(ns=1;i=100))') uawidgets.utils - ERROR - The requested node id is already used by another node.(BadNodeIdExists)') Traceback (most recent call last): File "C:\WPy64-3741\python-3.7.4.amd64\lib\site-packages\uawidgets\utils.py", line 21, in wrapper result = func(self, *args) File "C:\WPy64-3741\python-3.7.4.amd64\lib\site-packages\uamodeler\uamodeler.py", line 260, in import_xml self._model_mgr.import_xml(path) File "C:\WPy64-3741\python-3.7.4.amd64\lib\site-packages\uamodeler\model_manager.py", line 99, in import_xml new_nodes = self.server_mgr.import_xml(path) File "C:\WPy64-3741\python-3.7.4.amd64\lib\site-packages\uamodeler\server_manager.py", line 68, in import_xml return self._backend.import_xml(path) File "C:\WPy64-3741\python-3.7.4.amd64\lib\site-packages\uamodeler\server_manager.py", line 112, in import_xml return self._server.import_xml(path) File "C:\WPy64-3741\python-3.7.4.amd64\lib\site-packages\opcua\server\server.py", line 469, in import_xml return importer.import_xml(path, xmlstring) File "C:\WPy64-3741\python-3.7.4.amd64\lib\site-packages\opcua\common\xmlimporter.py", line 67, in import_xml node = self._add_node_data(nodedata) File "C:\WPy64-3741\python-3.7.4.amd64\lib\site-packages\opcua\common\xmlimporter.py", line 92, in _add_node_data node = self.add_datatype(nodedata) File "C:\WPy64-3741\python-3.7.4.amd64\lib\site-packages\opcua\common\xmlimporter.py", line 392, in add_datatype res[0].StatusCode.check() File "C:\WPy64-3741\python-3.7.4.amd64\lib\site-packages\opcua\ua\uatypes.py", line 233, in check raise UaStatusCodeError(self.value) opcua.ua.uaerrors._auto.BadNodeIdExists: The requested node id is already used by another node.(BadNodeIdExists)
Open Question
- Where is the default nodeset
Opc.Ua.NodeSet2.xml
loaded from and what version is it? - Where are downloaded 3rd party nodeset saved preferably?
Continue with Step 7
Be First to Comment