Python script to add libraries to project

tvm
2022-09-07
2025-11-11
  • tvm - 2022-09-07

    I've created the following python script to add certain libraries to a project. It seems to work fine, except for with certain libraries, placeholders don't get resolved. I've attached a screenshot of the library manager after the script runs. Is this an issue with my script, or something to do with the libraries themselves? The strange thing is that I have a project with two applications, and on each one different libraries resolve correctly.

    from __future__ import print_function
    
    Project = projects.primary
    AllObjects = Project.get_children(recursive=True)
    for LibManager in AllObjects:
       if LibManager.is_libman:
            for repo in librarymanager.repositories:
                print(repo.name, "(", repo.root_folder, ", ", repo.editable, ")")
                for lib in librarymanager.get_all_libraries(repo):
                    if lib.title == "Standard":
                        LibManager.add_placeholder("Standard", lib) 
                        print(lib.displayname, " added")
                    if lib.title == "CmpLog":
                        LibManager.add_placeholder("CmpLog", lib) 
                        print(lib.displayname, " added")    
                    if lib.title == "Visu Utils":
                        LibManager.add_placeholder("VisuUtils", lib) 
                        print(lib.displayname, " added")        
                    if lib.title == "PRO Standard":
                        LibManager.add_placeholder("PRO_Standard", lib) 
                        print(lib.displayname, " added")
                    elif lib.title == "PRO Time":
                        LibManager.add_placeholder("PRO_Time", lib)     
                        print(lib.displayname, " added")
                    elif lib.title == "PRO Message":
                        LibManager.add_placeholder("PRO_Message", lib)
                        print(lib.displayname, " added")
                    elif lib.title == "PRO Email":
                        LibManager.add_placeholder("PRO_Email", lib)     
                        print(lib.displayname, " added")    
                    elif lib.title == "PRO Trend":
                        LibManager.add_placeholder("PRO_Trend", lib)     
                        print(lib.displayname, " added") 
                    elif lib.title == "PRO Visu":
                        LibManager.add_placeholder("PRO_Visu", lib)     
                        print(lib.displayname, " added")
                    elif lib.title == "PRO File":
                        LibManager.add_placeholder("PRO_File", lib)     
                        print(lib.displayname, " added")
                    elif lib.title == "PRO Alarms":
                        LibManager.add_placeholder("PRO_Alarms", lib)     
                        print(lib.displayname, " added")
                    elif lib.title == "PRO Application":
                        LibManager.add_placeholder("PRO_Application", lib)     
                        print(lib.displayname, " added")
    
    print("script finished")
    
     
  • clockben - 2025-11-11

    Hello,

    I have the same issue β€” some libraries aren’t resolved.
    When I load the libraries manually and delete them, reloading with the script works fine afterward.

    Have you found a solution since then?

    Many thanks in advance

     

Log in to post a comment.