Hi. Thank you for the answer.
Implementing this I encountered something wierd. I have a method to find the PropertyValueGroup to add to my port:
@staticmethod
def get_property_value_group(capellaModel, propertyValuePkgName, propertyValueGroupName):
project = capellaModel.get_system_engineering().get_java_object().eContainer()
for pv_package in project.getOwnedPropertyValuePkgs().get(0).getOwnedPropertyValuePkgs():
if pv_package.getName() == propertyValuePkgName:
for pv_group in pv_package.getOwnedPropertyValueGroups():
print(pv_group)
if pv_group.getName() == propertyValueGroupName:
return PropertyValueGroup(pv_group)
I iterate over multiple objects, add a physical port (pp) an then call the following:
pvg = get_property_value_group(model, 'Snippet Design Domain', 'Snippet Port Allocation')
pp.get_java_object().getOwnedPropertyValueGroups().add(pvg.get_java_object())
pp.get_java_object().getAppliedPropertyValueGroups().add(pvg.get_java_object())
For the first element this works fine, but for the second the PropertyValueGroup named ‘Snippet Port Allocation’ is not present anymore. Here the console output containing the print statement from the method above:
Start adding snippetPort 'PI_POWER_NONE' to snippetInstance 'AUX_Supply_Fuse'
org.polarsys.capella.core.data.capellacore.impl.PropertyValueGroupImpl@ea49e27 (id: 16c59e7d-179a-4afb-acd5-f71ed9ac41eb, sid: _qNB8gPd2EeyhxaUKB8OeLQ) (name: Snippet Allocation) (visibleInDoc: true, visibleInLM: true, summary: null, review: null)
org.polarsys.capella.core.data.capellacore.impl.PropertyValueGroupImpl@5baded37 (id: a6b331bd-c42f-41cf-8596-df0991bd799d, sid: _Yzw0kA8lEe25A6P9TGVpoQ) (name: Snippet Port Allocation) (visibleInDoc: true, visibleInLM: true, summary: null, review: null)
Adding successfull!
Start adding snippetPort 'PO_POWER_NONE' to snippetInstance 'AUX_Supply_Fuse'
org.polarsys.capella.core.data.capellacore.impl.PropertyValueGroupImpl@ea49e27 (id: 16c59e7d-179a-4afb-acd5-f71ed9ac41eb, sid: _qNB8gPd2EeyhxaUKB8OeLQ) (name: Snippet Allocation) (visibleInDoc: true, visibleInLM: true, summary: null, review: null)
org.polarsys.capella.core.data.capellacore.impl.PropertyValueGroupImpl@545d9128 (id: 4c27e7d2-34ca-4324-b0b3-72e05ea16f36, sid: _eh-8YBIqEe20JZa14ka6eA) (name: Snippet Link Allocation) (visibleInDoc: true, visibleInLM: true, summary: null, review: null)
org.polarsys.capella.core.data.capellacore.impl.PropertyValueGroupImpl@11a3a80 (id: 81e720af-925d-4a6f-b627-9d0e4458b572, sid: _foq4EsPpEe2dIo-kaSPCmA) (name: Snippet Net Allocation) (visibleInDoc: true, visibleInLM: true, summary: null, review: null)
org.polarsys.capella.core.data.capellacore.impl.PropertyValueGroupImpl@154f7867 (id: 5dc901db-b9d2-4dbc-8b4d-5dc17cfecea6, sid: _HksgQBSmEe289rq7SVqFyQ) (name: Snippet External Interface Allocation) (visibleInDoc: true, visibleInLM: true, summary: null, review: null)
org.polarsys.capella.core.data.capellacore.impl.PropertyValueGroupImpl@1221611f (id: 142fc9c1-9c5c-4d8b-9c4c-7cee3e1aa775, sid: _ikBxgJsOEe2ncoHrfAQzsw) (name: Snippet Design Allocation) (visibleInDoc: true, visibleInLM: true, summary: null, review: null)
‘Snippet Port Allocation’ should be the second element in the list return by pv_package.getOwnedPropertyValueGroups() as during the first call, but it is not there anymore. Is there an obvious reason for this behaviour?
If I alter the script so that it runs through the ‘Snippet Port Allocation’ group is also not longer present in Capella using the PVMT Add-On.
Kind regards
Janis