Main Content


Get selected objects in Requirements Editor, Requirements Browser, or Requirements Table block

Since R2021a



    myReqObj = slreq.getCurrentObject returns the currently selected item or items in the Requirements Editor or Requirements Browser, or the currently selected requirement in a Requirements Table block.


    If you select an item and then select an item or group of items in a different window or block, the function returns the most recently selected item or group of items.


    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 Perspective.

    Open the CruiseRequirementsExample 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]

    Create a new model and add a Requirements Table block to the model.

    Open the block to view the empty requirement.

    This shows the inside of a new Requirements Table block. It contains one blank requirement.

    Click the index number to select the requirement.

    Get the slreq.Requirement object for the selected requirement.

    myReqObj = slreq.getCurrentObject;

    Output Arguments

    collapse all

    Requirements Toolbox object, returned as a:


    • If you execute this function during Requirements Toolbox callbacks, the function returns the target of the callback:

      • PreImportFcn — Returns empty when you are importing requirements. Returns a handle to the Import node when you are updating requirements.

      • PostImportFcn — Returns a handle to the Import node. If you are importing multiple specifications from a ReqIF™ file, the function returns an array of Import nodes. For more information, see Import Requirements from ReqIF Files.

      • PostLoadFcn — Returns a handle to the requirement set.

      • PreSaveFcn — Returns a handle to the requirement set.

      For more information, see Use Callbacks to Customize Requirement Import Behavior and Execute Code When Loading and Saving Requirement Sets.

    Version History

    Introduced in R2021a