Borrar filtros
Borrar filtros

How can I access child stereotype attributes of System Composer model in Matlab?

1 visualización (últimos 30 días)
Hello,
I have build a System Composer model where I have four stereotypes: the order of inheritance is "mainElement" > "componentType" > "componentAttributes" > "component", "mainElement" has no base stereotype.
Now I want to calculate the weight of the attached model "FCS_Architecture_Boeing_777". When I try to access the value of the attribute "unitWeight" of the stereotype "component", it says " Unrecognized method, property, or field 'component' for class 'systemcomposer.arch.Component' " in line 47 in "computeOverallSysWeight". I created another stereotype "Component" (with capital C!) without base stereotype. When I want to access this one it works.
Is there a possibility to access "child stereotypes" and their attribute values?
Thanks in advance.
Benjamin

Respuestas (1)

Feimi
Feimi el 20 de Oct. de 2023
Hi Benjamin,
systemcomposer.arch.Component is the object type in our public API and its documentation is here:
In order to access a property (attribute in your question) of a stereotype that is applied on your component, you can use the following command:
value = myComponent.getPropertyValue('DataModel.component.unitWeight') % myComponent is a systemcomposer.arch.Component object
There are some examples of the usage of this function documented here: https://www.mathworks.com/help/systemcomposer/ref/systemcomposer.arch.architecture.getpropertyvalue.html
Additionally, I assume that your use case is to calculate the weight by summing up the weights of every component. In that case, we shipped a workflow (in 2020b) that exactly fits your need. Please take a look at this example:
Feimi

Categorías

Más información sobre System Composer en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by