How to create a new VP requirement with Python4Capella

Hi all,
I try to create new VP requirements using Python4Capella. I don’t succeed in openning a CapellaModule to create them.
I Scripted it but have this Error Message:

Could you help me?

david

Sorry, here is the real error message:

The error is probably before the lines of the script you are sharing. I would be curious to know what’s in your LogicalArchitecture variable. The way you write this variable makes it look like you’re using the LogicalArchitecture class definition, where you should be using the logicalArchitecture model element.
Stephane

Hi Stéphane,
Thank you for your quick answer. You are right!
Here is the good script:

model = CapellaModel()
model.open(aird_path)
se = model.get_system_engineering()
la=se.get_logical_architecture()
module = RequirementAddOn()
for cm in module.get_requirement_modules(la):
print(cm.get_long_name())
model.start_transaction()
try:
req = Requirement()
#set its name
req.set_long_name(“TOTO”)
#add the new Requirement
cm.get_owned_requirements().add(req)
except:
# if something went wrong we rollback the transaction
model.rollback_transaction()
raise
else:
# if everything is ok we commit the transaction
model.commit_transaction()
# save the Capella model
model.save()

You should not instanciate RequirementAddOn, instead use:

RequirementAddOn.get_requirement_modules(la)