Main Content

setProperty

Set property value corresponding to stereotype applied to element

Description

setProperty(element,propertyName,propertyValue,propertyUnits) sets the value and units of the property specified in the propertyName argument. Set the property corresponding to an applied stereotype by qualified name "<profile>.<stereotype>.<property>".

example

Examples

collapse all

In this example, weight is a property of the stereotype sysComponent.

Create a model with a component called "Component".

model = systemcomposer.createModel("archModel");
systemcomposer.openModel("archModel");
arch = get(model,"Architecture");
comp = addComponent(arch,"Component");

Create a profile with a stereotype and properties, open the Profile Editor, then apply the profile to the model.

profile = systemcomposer.profile.Profile.createProfile("LatencyProfile");
latencybase = profile.addStereotype("LatencyBase");
latencybase.addProperty("latency",Type="double");
latencybase.addProperty("dataRate",Type="double",DefaultValue="10");
systemcomposer.profile.editor(profile)
model.applyProfile("LatencyProfile");

Apply the stereotype to the component, and set a new latency property.

applyStereotype(comp,"LatencyProfile.LatencyBase")
setProperty(comp,"LatencyProfile.LatencyBase.latency","500")

In this example, description is a property of the stereotype sysComponent.

Create a model with a component called Component.

model = systemcomposer.createModel("archModel");
systemcomposer.openModel("archModel");
arch = get(model,"Architecture");
comp = addComponent(arch,"Component");

Create a profile with a stereotype, then apply the profile to the model. Open the Profile Editor.

profile = systemcomposer.profile.Profile.createProfile("sysProfile");
base = profile.addStereotype("sysComponent");
base.addProperty("description",Type="string");
model.applyProfile("sysProfile");
systemcomposer.profile.editor

Apply the stereotype to the component, and set a new description property.

applyStereotype(comp,"sysProfile.sysComponent")
expression = sprintf("'%s'","component description")
setProperty(comp,"sysProfile.sysComponent.description",expression)

Set the AutoProfile.System.Cost property on the FOB Locator System component.

Launch the keyless entry system project.

scKeylessEntrySystem

Load the model and find the FOB Locator System component.

model = systemcomposer.loadModel("KeylessEntryArchitecture");
comp = lookup(model,Path="KeylessEntryArchitecture/FOB Locator System");

Set the Cost property on the component.

setProperty(comp,"AutoProfile.System.Cost","200","USD")

Input Arguments

collapse all

Name of property, specified as a character vector or string in the form '<profile>.<stereotype>.<property>'.

Data Types: char | string

Value of property, specified as a character vector or string. Specify string values in the form sprintf("'%s'",'<contents of string>'). For more information, see Apply a Stereotype and Set String Property Value.

Data Types: char | string

Units of property to interpret property values, specified as a character vector or string.

Data Types: char | string

More About

collapse all

Version History

Introduced in R2019a