主要内容

本页采用了机器翻译。点击此处可查看英文原文。

hasProperty

查找元素是否具有属性

自 R2021a 起

    说明

    如果 property 属性已添加到模型元素 element 上,则 result = hasProperty(element,property) 返回 true

    示例

    示例

    全部折叠

    从应用了 weight 构造型的组件中获取 sysComponent 属性。

    创建一个带有名为 Component 的组件的模型。

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

    创建带有构造型和属性的配置文件,然后将配置文件应用于模型。

    profile = systemcomposer.profile.Profile.createProfile("sysProfile");
    base = profile.addStereotype("sysComponent");
    base.addProperty("weight",Type="double",DefaultValue="10",Units="g");
    model.applyProfile("sysProfile")

    将构造型应用于组件,然后设置新的权重属性。

    applyStereotype(comp,"sysProfile.sysComponent")
    setProperty(comp,"sysProfile.sysComponent.weight","5","g")

    查找组件上是否存在权重属性。

    result = hasProperty(comp,"sysProfile.sysComponent.weight")
    
    result =
    
      logical
    
       1

    输入参数

    全部折叠

    属性,指定为字符向量或字符串,格式为 "<profile>.<stereotype>.<property>"

    数据类型: char | string

    输出参量

    全部折叠

    查询结果,以 1 (true) 或 0 (false) 的形式返回。

    数据类型: logical

    详细信息

    全部折叠

    版本历史记录

    在 R2021a 中推出