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()?

Answers (1)

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

Categories

Find more on System Composer in Help Center and File Exchange

Products

Release

R2025b

Asked:

on 29 Apr 2026 at 14:06

Answered:

about 3 hours ago

Community Treasure Hunt

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

Start Hunting!