I want to add a library avalible in my librarymanager to the "real" library manager of the project. Also i need to access propertys of the librarys in my primary project e.g. last change, licence required, released.
I would assume to have a list of librarys under projects.primary, but nothing.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Nina hat geschrieben:
I want to add a library avalible in my librarymanager to the "real" library manager of the project. Also i need to access propertys of the librarys in my primary project e.g. last change, licence required, released.
I would assume to have a list of librarys under projects.primary, but nothing.
It is the same as in the Navigator. You have to look for the objects which are Library Manager Objects short LibManObject. The Scripting objects, which are LibManObjects, return True for the property .
Here some example code which prints the list of referenced libraries:
proj=projects.primaryobjects=proj.get_children(recursive=True)forcandidateinobjects:
  ifcandidate.is_libman:
    forlibrefiniter(candidate):
      iflibref.is_placeholder:
        print"placeholder: %s: %s => %s"%(libref.name, libref.default_resolution, libref.effective_resolution)
        params=libref.parameters
        fornameinparams:
          print"  param: %s => %s"%(name, params[name])
      eliflibref.is_managed:         Â
        print"library: %s: %s"%(libref.name, libref.managed_library.version)
      else:         Â
        print"library: "+libref.name
BR
Martin
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Actually this wasn't working for me as candidate.is_libman returns the library manager in POU but not the one in Device/Application/library manager.
However, I tried to take you example and get it working, but Libref still does not provide me the properties I would expect:
from__future__importprint_functionObjects=projects.primary.get_children()forDeviceinObjects:
  ifDevice.is_device:
    forPlcLogicinDevice.get_children():
      ifPlcLogic.get_name()=='Plc Logic':
        forAppinPlcLogic.get_children():
          ifApp.is_application:
            LibMan=App.get_library_manager()             Â
            forLibrefinLibMan.references:
              ifLibref.is_placeholder:
                print("placeholder: %s: %s => %s"%(Libref.name,Libref.default_resolution,Libref.effective_resolution))
                params=Libref.parameters
                fornameinparams:
                  print("  param: %s => %s"%(name,params[name]))
              elifLibref.is_managed:         Â
                print("library: %s: %s"%(Libref.name,Libref.managed_library.version))
              else:         Â
                print("library: "+Libref.name)
Nina hat geschrieben:
Also i need to access propertys of the librarys in my primary project e.g. last change, licence required, released.
Nina
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Nina hat geschrieben:
Actually this wasn't working for me as candidate.is_libman returns the library manager in POU but not the one in Device/Application/library manager.
My example works but it does not say which part of the output belongs to which LibManObject.
Nina hat geschrieben:
Also i need to access propertys of the librarys in my primary project e.g. last change, licence required, released.
The information from your screenshot is in the "Project Information" object of the library itself.
See the chapter "Example: Manipulation of the object Project information" in our documetation if the library/project is loaded and you want to access the project information.
The libraries, which are referenced by the LibManObjects, are automatically loaded after the primary project is loaded. So you can go through the list of loaded projects and look for the projects which are a library.
Here my example for printing the paths of the loaded projects:
forprojinprojects.all:
  print("Project Handle: {} IsLib: {} Path: {}".format(proj.handle, proj.library, proj.path))
BR
Martin
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Nina hat geschrieben:
Just a comment to the referred documentation: The impotent link "API Reference Documentation for the ScriptEngine" isn't working.
We know and have an entry in our bug tracking but you can use the CHM file "ScriptEingine.chm" in the sub directory "Online Help" or in the language specific sub directory below it.
BR
Martin
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This example shows how to add a library to the library repository (even if the object is called "librarymanager") :
https://help.codesys.com/api-content/1/codesys/3.5.11.0/de/cds-access-cds-func-in-python-scripts/
I want to add a library avalible in my librarymanager to the "real" library manager of the project. Also i need to access propertys of the librarys in my primary project e.g. last change, licence required, released.
I would assume to have a list of librarys under projects.primary, but nothing.
Hi Nina.
It is the same as in the Navigator. You have to look for the objects which are Library Manager Objects short LibManObject. The Scripting objects, which are LibManObjects, return True for the property .
Here some example code which prints the list of referenced libraries:
BR
Martin
Thanks Martin for your quick replay.
Actually this wasn't working for me as candidate.is_libman returns the library manager in POU but not the one in Device/Application/library manager.
However, I tried to take you example and get it working, but Libref still does not provide me the properties I would expect:
Nina
Hi Nina.
My example works but it does not say which part of the output belongs to which LibManObject.
The information from your screenshot is in the "Project Information" object of the library itself.
See the chapter "Example: Manipulation of the object Project information" in our documetation if the library/project is loaded and you want to access the project information.
The libraries, which are referenced by the LibManObjects, are automatically loaded after the primary project is loaded. So you can go through the list of loaded projects and look for the projects which are a library.
Here my example for printing the paths of the loaded projects:
BR
Martin
Thanks, that's working!
Just a comment to the referred documentation: The impotent link "API Reference Documentation for the ScriptEngine" isn't working.
Nina
Hi Nina.
We know and have an entry in our bug tracking but you can use the CHM file "ScriptEingine.chm" in the sub directory "Online Help" or in the language specific sub directory below it.
BR
Martin