Main Content

systemcomposer.view.ElementGroup

Architecture view element group

    Description

    An ElementGroup object is used to manage element groups in architecture views for a System Composer™ model.

    Creation

    Create a view and get the Root property.

    objView = createView(objModel);
    objElemGroup = objView.Root

    The createView method is the constructor for the systemcomposer.view.View class. The Root property returns the systemcomposer.view.ElementGroup that defines the view.

    Properties

    expand all

    Name of element group, specified as a character vector.

    Example: 'NewElementGroup'

    Data Types: char

    Universal unique identifier for element group, specified as a character vector.

    Example: '91d5de2c-b14c-4c76-a5d6-5dd0037c52df'

    Data Types: char

    Elements in view, specified as a array of systemcomposer.arch.BaseComponent objects.

    Subgroups under the parent element group, specified as an array of systemcomposer.view.ElementGroup objects.

    Object Functions

    addElementAdd component to element group of view
    removeElementRemove component from element group of view
    createSubGroupCreate subgroup in element group of view
    getSubGroupGet subgroup in element group of view
    deleteSubGroupDelete subgroup in element group of view
    destroyRemove model element

    Examples

    collapse all

    Use a keyless entry system to programmatically create architecture views.

    1. Import the package with queries.

    import systemcomposer.query.*

    2. Open the Simulink® project file for the Keyless Entry System.

    scKeylessEntrySystem

    3. Load the example model into System Composer™.

    model = systemcomposer.loadModel('KeylessEntryArchitecture');

    Example 1: Hardware Component Review Status View

    Create a filtered view that selects all hardware components in the architecture model and groups them using the ReviewStatus property.

    1. Construct a query to select all hardware components.

    hwCompQuery = HasStereotype(IsStereotypeDerivedFrom('AutoProfile.HardwareComponent'));

    2. Use the query to create a view.

    model.createView('Hardware Component Review Status',...
     'Select',hwCompQuery,... % Query to use for the selection
     'GroupBy',{'AutoProfile.BaseComponent.ReviewStatus'},... % Stereotype property to qualify by
     'IncludeReferenceModels',true,... % Include components in referenced models
     'Color','purple');

    3. To open the Architecture Views Gallery the Views section, click Architecture Views.

    model.openViews
    

    Example 2: FOB Locator System Supplier View

    Create a freeform view that manually pulls the components from the FOB Locator System and groups them using existing and new view components for the suppliers. In this example, you will use element groups, groupings of components in a view, to programmatically populate a view.

    1. Create a view architecture.

    fobSupplierView = model.createView('FOB Locator System Supplier Breakdown',...
        'Color','lightblue');

    2. Add a subgroup called 'Supplier D'. Add the FOB Locator Module to the view element subgroup.

    supplierD = fobSupplierView.Root.createSubGroup('Supplier D');
    supplierD.addElement('KeylessEntryArchitecture/FOB Locator System/FOB Locator Module');

    3. Create a new subgroup for 'Supplier A'.

    supplierA = fobSupplierView.Root.createSubGroup('Supplier A');

    4. Add each of the FOB Receivers to view element subgroup.

    FOBLocatorSystem = model.lookup('Path','KeylessEntryArchitecture/FOB Locator System');
    
    % Find all the components which contain the name "Receiver"
    receiverCompPaths = model.find(...
        contains(Property('Name'),'Receiver'),...
        FOBLocatorSystem.Architecture);
    
    supplierA.addElement(receiverCompPaths)

    5. Save the model.

    model.save

    More About

    expand all

    Introduced in R2021a