way to open the libraries from an open project.

Anonymous
2016-11-30
2016-12-01
  • Anonymous - 2016-11-30

    Originally created by: Geert Vanstraelen

    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

     
  • mkeller - 2016-12-01

    Hi.

    Geert Vanstraelen hat geschrieben:
    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".

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

    BR
    Martin

     
  • Anonymous - 2016-12-01

    Originally created by: Geert Vanstraelen

    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

    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)
    
     

Log in to post a comment.