Main Content

slreq.getCurrentObject

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

Since R2021a

    Description

    example

    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.

    Note

    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.

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

    Open the myAddRequirements requirement set in the Requirements Editor.

    slreq.open("myAddRequirements");

    In the Requirements Editor, select the requirement with the index 1.

    myReqObj = slreq.getCurrentObject;

    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:

    Tips

    • 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