Main Content


Selected objects in Requirements Editor or Requirements Browser



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


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


    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.


    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]


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


    Output Arguments

    collapse all

    Simulink Requirements object, returned as a:

    Introduced in R2021a