Function for adding requirement module to architecture?

I am able to add folders to modules, requirements to folder, attributes to requirements, but I have not made/found a solution to add modules to architectures. If anyone has a solution or has access to a requirement api that has more functions that are working than the default requirement file that would be extremely appreciated. 

Is it just me or is RequirementVP very underdeveloped? If there are resources that I'm missing that can make manipulating requirements a breeze I may get some sleep at night.

The Python4Capella API covers mainly the getter part of Capella. It’s the same with the requirement addon API.

The requirement API has been improved in version 1.2.0. But still miss the method you need.

You can use the Java API to do this:

myArch = LogicalArchitecture()
myModule = CapellaModule()

myArch.get_java_object().getOwnedExtensions().add(myModule.get_java_object())

I opened an issue:

Sweet, thank you. I was also curious if there is a way to assign capella elements to requirement in/out links through P4C?

CODE:
ab = AbstractRelation(ReqIFElement(EObject(componentTest.get_java_object())))

ERROR:
AttributeError: ‘EObject’ object has no attribute ‘_get_object_id’

also tried passing the java object to ReqIFElement
also tried passing java object of EObject

You can connect requirements to CapellaElement like this:

req1 = Requirement()
element1 = LogicalComponent()
element2 = LogicalComponent()
req2 = Requirement()

incomingRelation = CapellaIncomingRelation()
incomingRelation.set_source(req1)
incomingRelation.set_target(element1)

outgoingRelation = CapellaOutgoingRelation()
outgoingRelation.set_source(element2)
outgoingRelation.set_target(req1)

internalRelation = InternalRelation()
internalRelation.set_source(req1)
internalRelation.set_target(req2)

req1.get_owned_relations().add(incomingRelation)
req1.get_owned_relations().add(outgoingRelation)
req1.get_owned_relations().add(internalRelation)

This is the error I’m getting with the code portion below it. To give more context of what I’m trying to do: I’m creating a module that has a folder for each logical component in the project and creating two template requirements inside each folder that already sets the outgoing relation to the corresponding logical component.

My mistake I inverted the Requirement and the CapellaElement in CapellaIncomingRelation and
CapellaOutgoingRelation. I fixed the above example.

1 Like