[HELP] Import requirements from CSV/EXCEL to CAPELLA #105
-
Hi, Using the package "capellambse" I manage quite easily to handle the export from CAPELLA to CSV/EXCEL but I'm facing difficulties to handle the other way. My main problem is that so far I didn't acheive to custom attributes to my requirement "on the fly" with my script.
How to add custom attributes fields to my object REQ ? Thanks in advance for support, Jérémy |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 14 replies
-
nice use case indeed, I think we can add an example for how to create a req attribute into https://github.com/DSD-DBS/py-capellambse/blob/master/examples/06%20Introduction%20to%20Requirement%20access%20and%20management.ipynb or maybe even an example for excel import with attribute definition creation. The catch there was about having the definitions / enums pre defined or imported upfront. @ewuerger , @Wuestengecko - since you are deep in this topic now, would any of you have time to add a quick example for attr instantiation? |
Beta Was this translation helpful? Give feedback.
-
Capella (Requirements plugin) is doing that in an overengineered way. While implementing some Requirement Bots that automate maintenance we used the API to its full extent already. Just to get you going instead of waiting for a demo notebook: from capellambse.extensions import reqif
requirement = model.search(reqif.XT_REQUIREMENT)[0]
requirement.attributes.create("int", name="Example", value=10) If you forget to handover the type hint (here "int") then the API will tell you to do so, since this is needed for creation. Possible types are:
Then this is all you need to create attribute values underneath your requirements. But if you want to add a requirement type and/or definition to the reqtfolder = model.la.requirement_types_folders[0]
reqtype = reqtfolder.requirement_types[0]
reqtype.attribute_definitions.create(reqif.XT_REQ_TYPE_ATTR_DEF, long_name="Example Definition")
new_req_attr = requirement.attributes[-1]
new_req_attr.type = reqtype
new_req_attr.definition = reqtype.attribute_definitions[0] or handover while creation of attributes: definition = reqtype.attribute_definitions.by_long_name("Example Definition")
requirement.attributes.create("int", name="Example", type=reqtype, definition=definition) We like the latter more. Also this will improve the display of Key takeaways:
We'll work on improving documentation and showcases in the future. After that it will be a walk in the park to get your Pandas DataFrame content back into Capella. Maybe if you are invested, you can try to extent reqif to offer import from excel-file? |
Beta Was this translation helpful? Give feedback.
-
Hi, I have a question related to this one. In the case the attribute already exists in the model, if I want to update its value, how can I do it? Which method should I call, please? Thanks in advance, |
Beta Was this translation helpful? Give feedback.
Capella (Requirements plugin) is doing that in an overengineered way. While implementing some Requirement Bots that automate maintenance we used the API to its full extent already. Just to get you going instead of waiting for a demo notebook:
In order to add
AttributeValue
s to a Requirement you can use the same create functionality as seen in the notebook. Here it would go like this:If you forget to handover the type hint (here "int") then the API will tell you to do so, since …