Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add a property to a SubmodelElementCollection? #125

Closed
JS-Aibel opened this issue Sep 26, 2023 · 2 comments
Closed

How to add a property to a SubmodelElementCollection? #125

JS-Aibel opened this issue Sep 26, 2023 · 2 comments

Comments

@JS-Aibel
Copy link

JS-Aibel commented Sep 26, 2023

Hi,

How do I add a property to a SubmodelElementCollection?

With the following code I am able to create and add a SubmodelElementCollection to a Submodel.

smc= model.SubmodelElementCollectionUnordered(id_short="TestSME")
submodel.submodel_element.add(smc)

I am not able to add a property to that smc. The following code below gives error: AttributeError: 'SubmodelElementCollectionUnordered' object has no attribute 'submodel_element'.

smc.submodel_element.add(property_)

Is there a way to add a property to a SubmodelElementCollection?

@jkhsjdhjs
Copy link
Contributor

Yes, SubmodelElements are contained in the value attribute of a SubmodelElementCollection. Thus, you should be able to add the propety via

smc.value.add(property_)

or alternatively

smc.add_referable(property_)

@JS-Aibel
Copy link
Author

Yes, SubmodelElements are contained in the value attribute of a SubmodelElementCollection. Thus, you should be able to add the propety via

smc.value.add(property_)

or alternatively

smc.add_referable(property_)

Nice, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants