System Composer API - setProperty function with batch pattern

Hello,
I'd like to import many external data elements as interface elements with some additonal properties (around 20) via Matlab script to a System Composer data dictionary within a single interface. The current import duration is quite long due to a lot of calls of the setProperty function for each element.
Is there a possibility to set all properties belonging to a stereotype of an interface element with Name-Value lists as a batch argument in order to reduce the amount of the System Composer API call of setProperty()?

Respuestas (2)

Samar
Samar el 7 de Mayo de 2026
Hi MaVo,
As of the current System Composer API, there is no documented “batch” setter that accepts a Name‑Value list (or struct/map) to set multiple stereotype properties in one call for an interface element. The documented setProperty API sets exactly one stereotype property per call (identified by the qualified name <profile>.<stereotype>.<property>). Please find the MathWorks documentation on 'setProperty()' here: https://in.mathworks.com/help/systemcomposer/ref/systemcomposer.arch.architecture.setproperty.html
So, if you need to populate ~20 properties per element, you will still end up making ~20 API calls per element using the public API.
But you can try the following methods for reducing runtime:
1) Use stereotype "DefaultValue" aggressively
Define common property values as defaults in the stereotype, and override only the element‑specific ones. This significantly reduces the number of setProperty calls per element.
2) Apply stereotypes in bulk, then set properties (avoid repeated apply cost)
Apply profiles and stereotypes once, not repeatedly inside loops. Avoid re‑applying stereotypes during element creation; only set properties afterward.
3) Minimize dictionary I/O: save once at the end
Avoid frequent saves. Perform all element creation and property updates first, then call dictionary.save once at the end to reduce I/O overhead.
4) Reduce overhead in your loop (micro-optimizations that often matter)
Precompute qualified property names, reuse them inside loops, and avoid redundant checks. Set properties only when values differ from defaults or are actually needed.
5) Consider modeling the “20 extra fields” differently if they’re mostly data attributes
If many fields describe data characteristics (units, dimensions, min/max, type), move them into Value Types or interface typing instead of stereotype properties to reduce per‑element property updates.
Hope this helps!
Regards,
Samar
Josh Kahn
Josh Kahn el 19 de Jun. de 2026 a las 14:00
Hi @MaVo,
Have you tried importing via MATLAB tables? You can set stereotype property values for all of your elements that way instead
Josh

2 comentarios

MaVo
MaVo hace alrededor de 3 horas
Editada: MaVo hace alrededor de 3 horas
thank you for the hint! I did try this with a modification of the UAV example, which is linked to the importer function documentation (systemcomposer.importModel - Import model information from MATLAB tables - MATLAB). I tried this with R2025b and an AUTOSAR SW Architecture model.
I noticed this:
  • Interface data gets only imported to the "Model Workspace", not to the data dictionary which is linked to the model
  • Additional custom "meta data" columns in the excel sheet tab for PortInterfaces (e.g. 'isSafety', 'UUID', etc...) do not find their way as a stereotype property into the model workspace nor data dictionary
Could you maybe provide a minimum example, where an external data source with Interface information and additonal metadata information (.xlsx or .json) is transferred to the MATLAB tables and gets fully imported into a data dictionary linked to the model, in which the imported data in the dictionary is enhanced with a stereotype that collects all the metadata information as properties and stores them to the inported elements?
Hey @MaVo, glad this is helping you make progress!
The best example would be for you to make a toy model in System Composer the way you want it to be imported, and use the export API. Then just match your tables to the exported tables.
For profiles and stereotypes, make sure to name the columns using the format: MyProfileName_MyStereotypeName_MyPropertyName
After import, to save the interfaces from the model workspace:
Josh

Iniciar sesión para comentar.

Categorías

Más información sobre System Composer en Centro de ayuda y File Exchange.

Productos

Versión

R2025b

Preguntada:

el 29 de Abr. de 2026

Comentada:

hace alrededor de 3 horas

Community Treasure Hunt

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

Start Hunting!

Translated by