Main Content

slreq.getCurrentObject

Selected objects in Requirements Editor or Requirements Browser

    Description

    example

    myReqObj = slreq.getCurrentObject returns the currently selected item or items in the Requirements Editor or Requirements Browser.

    Note

    If you select an item in both the Requirements Editor and the Requirements Browser, the function returns the most recently selected item.

    Examples

    collapse all

    This example shows how to get the object for the most recently selected item or items in the Requirements Editor or the Requirements Browser.

    Open the Requirements Definition for a Cruise Control Model project. Load the crs_req_func_spec requirement set and open it in the Requirements Editor.

    slreqCCProjectStart;
    slreq.open('crs_req_func_spec');

    In the Requirements Editor, select requirement #1: Driver Switch Request Handling. Get the object for the selected requirement, then inspect the incoming links.

    myReqObj = slreq.getCurrentObject;
    lk = slreq.inLinks(myReqObj)
    lk = 
      Link with properties:
    
               Type: 'Implement'
        Description: '#1: Driver Switch Request Handling'
           Keywords: {}
          Rationale: ''
          CreatedOn: 20-May-2017 11:19:44
          CreatedBy: 'itoy'
         ModifiedOn: 17-Aug-2017 14:41:16
         ModifiedBy: 'itoy'
           Revision: 1
                SID: 1
           Comments: [0×0 struct]
    
    

    Cleanup

    Clear the open requirement sets and link sets, and close the Requirements Editor.

    slreq.clear;

    Output Arguments

    collapse all

    Simulink Requirements object, returned as a:

    Introduced in R2021a