CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum
Deutsche Version English version russian version 
It is currently Tue May 23, 2017 6:03 am

All times are UTC+01:00




Post new topic  Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Wed Nov 30, 2016 4:54 pm 
Offline

Joined: Thu Apr 28, 2016 8:22 am
Posts: 2
Hello,

I'm using the script language to access all types used in a program.
I started with the DevicePrintTree.py as an example and are able to find all types defined in the project.
Some types however are defined in libraries.

I have two problems:
- how can I find the path to the library file in the library manager?
- how can I open the library, while maintaining at the same time the projects.primary project open?

Best regards,

Geert Vanstraelen


Top
   
PostPosted: Thu Dec 01, 2016 10:09 am 
Offline
Frequent User
Frequent User

Joined: Tue Nov 13, 2012 9:20 am
Posts: 192
Hi.

Geert Vanstraelen wrote:
I have two problems:
- how can I find the path to the library file in the library manager?
- how can I open the library, while maintaining at the same time the projects.primary project open?

The libraries, which are required, are automatically loaded. Even the compiled libraries but they only contain "proxy objects".

Code:
for proj in projects.all:
   if proj.primary:
      print("Primary: %s" % proj.path)
   elif proj.library:
      print("Library: %s" % proj.path)

BR
Martin

_________________
Check out the CODESYS store: http://store.codesys.com/

CODESYS® a trademark of 3S-Smart Software Solutions GmbH
Inspiring Automation Solutions


Top
   
PostPosted: Thu Dec 01, 2016 6:49 pm 
Offline

Joined: Thu Apr 28, 2016 8:22 am
Posts: 2
Dear Martin,

Thank you for your solution, the access to projects.all and he path were the missing clues.
The loaded user libraries also seem to contain limited information.
By opening and closing them one by one I finished to have the information that I needed.

Best regards,

Geert

Code:
projectPath = ""
libraryPaths = []

print("--- List of all projects: ----------")
for proj in projects.all:
   if proj.primary:
      print("Primary: %s" % proj.path)
      projectPath = proj.path
   elif proj.library:
      print("Library: %s" % proj.path)
      if (proj.path.find("compiled") < 0):
         print("********** User library: %s" % proj.path)
         libraryPaths.append(proj.path)
      else:
         print("********** System library: %s" % proj.path)
print("------------------------------------")

for libPath in libraryPaths:
    projects.primary.close()
    lib = projects.open(libPath)
    parsetree(projects.primary, 1, 1)
projects.primary.close()
# Reopen our primary project
projects.open(projectPath)
parsetree(projects.primary, 1, 1)


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 3 posts ] 

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited