Closed Nelson1905 closed 1 month ago
This sample script doing this.
Thanks you, I saw this script but it not really that my question. I want to get Allocating_Requirement or Allocated_Requirement specifically from Logical Component. It is possible ?
I don't have the needed setup to test but the requirement addon of Capella comes with its own semantic browser queries:
And you can call them with the Python4Capella API, in you case:
myLogicalComponent.get_query_result("Allocated Requirements")
I already tried it but I got empty lists.
Do you have a stack trace ? With Java 17 there is an error because EASE doesn't have a java module name declaration. Maybe that's why the list is empty. Also the str method is not implemented correctly for the JavaList class from Python4Capella which might let you think the list is empty but it might not be.
When I print the list for elt in diagram.get_represented_elements() : print(elt.get_query_result("Allocated Requirements"), len(elt.get_query_result("Allocated Requirements")))
I don't get stack trace error but I got it :
Did you include the requirement.py module ?
# include needed for the requirement API
include('workspace://Python4Capella/simplified_api/requirement.py')
if False:
from simplified_api.requirement import *
If it's already the case, you can also try:
myLogicalComponent.get_query_result("Allocated Requirements", Requirement)
Python4Capella automatically wrap Java Object to Python objects and that might be the cause of your issue.
I resolve it, I needed to select that :
I didn't knew that... requirements queries are not available by default. Thank you for pointing that to me.
Hi,
I would like get with my python code Source and Target elements from Relation linked at a Component, but I didn't found in documentation functions allowing it.
I try severals functions like for example
get_incoming_linked_elems()
but I get empty lists or errors.Would you have any leads to share with me ?