Scripting Symbol Configuration

nico-cph
2020-03-09
2023-08-02
  • nico-cph - 2020-03-09

    Hi there,

    Relatively new to scripting on Codesys and I am having some problems with the Symbol Configuration - hopefully someone has solved that.

    I have tried various suggestions from this forum, but without success. Example:

    from System import Guid
    optimizedCalculator = Guid('{0141eb75-141b-4ea1-9a8c-75f952b22a6c}')
    app = projects.primary.active_application
    symbol = app.create_symbol_config(False, False, optimizedCalculator)
    print('Symbol config created')

    Error in the above is AttributeError 'ScriptObject' has no attribute 'create_symbol_configuration', but I have been various errors - depending on the example I have tried out.

    Basically i'm trying to create/generate the Symbol Configuration via a script, but it does not really succeed.

    Any links to a fully updated scripting API for Codesys is also appreciated. I have not been able to find much and a lot of links in the documentation just links to a page not found for this.

    I am trying to use this one from the scripting manual:

    Version added: 3.5.10.0
    create_symbol_config(export_comments_to_xml, support_opc_ua, client_side_layout_calculator)
    Add the symbol configuration object to an application.

    Return type: ScriptObject
    Returns: Script object of the symbol config object.

    Thanks

     

    Last edit: nico-cph 2020-03-09
    • mkeller - 2020-03-09

      Hi.

      Which version of CODESYS do you use?

      The creation of symbol config object via Scripting was added with CODESYS V3.5 SP10. If you use an older version of CODESYS it will not work.

      BR
      Martin

       
      • nico-cph - 2020-03-09

        Hi Martin

        Thanks for your switch reply.

        Just checked - I am using V3.5 SP15. So i reckon it should work right?

         
        • mkeller - 2020-03-10

          Hi.

          I tested it with CODESYS 64 V3.5 SP15 Patch 3 with a newly created standard project and the following python script:

          from System import Guid
          
          app = projects.primary.active_application
          
          optimizedCalculator = Guid('{0141eb75-141b-4ea1-9a8c-75f952b22a6c}')
          try:
              symbol = app.create_symbol_config(False, False, optimizedCalculator)
              print('Symbol config created')
          except InvalidOperationException as e:
              print('SymbolConfigObject could not be created: ' + str(e))
          

          BR
          Martin

           
          • kida - 2023-08-02

            Martin,

            Thanks for the valuable solution but how is it possible that I don't find the createsymbolconfig() method in the online help?
            This is not the first time when a posted solution on this forum uses undocumented methods. Am I searching at the wrong place or is there a trick? (It is quite hard to develop applications like this:) )
            Thanks for the answer!
            BR
            David

             

            Last edit: kida 2023-08-02

Log in to post a comment.