I was trying to exploit Python4Capella to set some attributes owned by requirements in my model, the script that I wrote is something like this:
# include needed for the Capella modeller API include('workspace://Python4Capella/simplified_api/capella.py') if False: from simplified_api.capella import * # include needed for the requirement API include('workspace://Python4Capella/simplified_api/requirement.py') if False: from simplified_api.requirement import * # include needed for utilities include('workspace://Python4Capella/utilities/CapellaPlatform.py') if False: from utilities.CapellaPlatform import * # include needed for the PVMT API include('workspace://Python4Capella/simplified_api/pvmt.py') if False: from simplified_api.pvmt import * # change this path to execute the script on your model (here is the IFE sample). # comment it if you want to use the "Run configuration" instead aird_path = '/TMS_test_5/TMS_test_5.aird' model = CapellaModel() model.open(aird_path) # gets the SystemEngineering and print its name se = model.get_system_engineering() for req in se.get_all_contents_by_type(Requirement): if str(req.get_id())=='1': if req.get_java_object().getOwnedAttributes() != None: for att in req.get_java_object().getOwnedAttributes(): if str(att.getDefinition().getReqIFLongName())=='Value': req.set_attribute(att.getDefinition().getReqIFLongName(),100)
Checking the requirement.py in the simplified_api on my device it turns out that the “set_attribute” function for requirements exists but it just raises an error:
def set_attribute(self, attributeName, value): """ status: KO """ raise AttributeError("TODO")
It’s this issue being solved or there is another way to do that?