Application Login via python

  • lvstrom

    lvstrom - 2021-01-04


    I trying to create a script in python which build the project and perform a download to the PLC.
    But when it tries to login an error occurs, that I do not know how to solve. See my attached picture.

    It only occurs when login via the script.

    I am using a Lenze PLC 3200C and Lenze PLC designer 3.21.
    This is my python code.

    from __future__ import print_function
    proj = projects.primary
    app = proj.active_application
    onlineapp = online.create_online_application(app)
    # Find device object
    found = proj.find('Device', False)
    assert(found and len(found) == 1, 'No or more than one device found')
    dev = found[0]
    gws = online.gateways
    for gw in gws:
        if == 'Gateway-1':
    PLC_address = gw.find_address_by_ip('')
    dev.set_gateway_and_address('Gateway-1', PLC_address)
    onlineapp.login(OnlineChangeOption.Never, False)
    if not onlineapp.application_state ==

    Thanks and best regards

    • Morberis

      Morberis - 2021-01-05

      Hopefully someone who knows sees this and can help. Unfortunately I don't have any experience in what you're trying to do so I just have some generic help, as well as what I've dug up doing my own google search.

      My first suggestion is to look on the Codesys Help page if you haven't done so already or if Lenze's IDE doesn't link to it. Looking at it myself it seems like this would be the relevant page within.

      I did find this post from someone trying to do something similar.

      If you can't get it figured out or don't have time to you will definately get your issue solved by purchasing a support ticket.

      Edit: I'm sorry, I tried clicking both "API Reference Documentation for the ScriptEngine" links and both lead to a blank page!

      I'll submit a bug report. In the meantime you might be able to find something by following these directions

      Before CODESYS V3.5 SP11 the ScriptEngine.chm was in the directory "Online Help" of the CODESYS installation path. With CODESYS V3.5 SP11 you can find in the file ScriptEngine.chm in the sub directory for the individual language of the directory "Online Help".

      Last edit: Morberis 2021-01-05

Log in to post a comment.