andyfox - 2021-06-07

I copied the code from https://help.codesys.com/webapp/_cds_access_cds_func_in_python_scripts;product=codesys;version=3.5.15.0 into a local file, "PrintDeviceTree.py". When I open the project in the IDE and execute the script file, it prints six messages, as expected. When I run the script from the command line, I get an error. It doesn't matter if I precede the command with "start /wait" or run it from a batch/command file. My goal is to be able to run a single script against any arbitrary project, extracting information about the project.

Here is the command:
c:\Users\afox>"C:\Program Files\CODESYS 3.5.16.10\CODESYS\Common\CODESYS.exe" --profile='CODESYS V3.5 SP16 Patch 1' --project='C:\Users\afox\Projects\SampleProject.project' --noUI --runscript='C:\Users\afox\PrintDeviceTree.py'

Here is the output:
c:\Users\afox>--- Printing the devices of the project: ---
Error: Running script 'C:\Users\afox\PrintDeviceTree.py' caused exception System.MissingMemberException: Traceback (most recent call last):
File "C:\Users\afox\PrintDeviceTree.py", line 34, in <module>
AttributeError: 'NoneType' object has no attribute 'get_children'</module>