Update Project Usages programatically

MagicDraw OpenAPI, scripting related questions and discussions

Moderator: Moderators

Update Project Usages programatically

Postby arne@kruegers.online » Fri May 26, 2023 7:57 am

I have a TeamWork Cloud project with many project usages and would like to update all of these to the latest trunk revision.

Code: Select all
from com.nomagic.magicdraw.openapi.uml import SessionManager
from com.nomagic.magicdraw.core import Application
from com.nomagic.magicdraw.core import Project
from com.nomagic.magicdraw.core import ProjectUtilities
from com.nomagic.magicdraw.core.modules import ModulesService

project = Application.getProject(Application.getInstance())
primaryProject = project.getPrimaryProject()
attachedProjects = ProjectUtilities.getAttachedProjects(primaryProject)

SessionManager.getInstance().createSession(project, "Update Project Usages")

for attachedProject in attachedProjects:
        ModulesService.setUsedVersionOnTask(primaryProject, attachedProject, ???)

ModulesService.setUsedVersionOnTask() is the closest I found in the OpenAPI documentation. It expects a version sting but I cannot get it to work.

Has anyone a working solution?
Forum Newbie
Forum Newbie
Posts: 9
Posts Rating:1
Joined: Thu Oct 07, 2021 4:19 am

Return to Programmatic Extendibility

Who is online

Users browsing this forum: No registered users and 1 guest