get_selected_objects - 2022.2 English

Vivado Design Suite Tcl Command Reference Guide (UG835)

Document ID
UG835
Release Date
2022-10-19
Version
2022.2 English

Get selected objects

Syntax

get_selected_objects [‑primary] [‑quiet] [‑verbose]

Returns

List of selected objects.

Usage

Name Description
[-primary] Do not include objects that were selected due to selection rules
[-quiet] Ignore command errors
[-verbose] Suspend message limits during command execution

Categories

Object, GUIControl

Description

Gets the objects currently selected in the Vivado® IDE by the select_objects command. Can get the primary selected object and any secondary selected objects as well.
Note: This Tcl command works only when Vivado is run in GUI mode.

Primary objects are directly selected, while secondary objects are selected based on the selection rules currently defined by the Tools > Settings command. Refer to the Vivado Design Suite User Guide: Using the IDE (UG893) for more information on setting selection rules.

This command returns a Tcl list of selected objects, even a list with just one object. This can be an issue for some of the Vivado tool commands that do not accept a list of objects, such as the current_instance command. In this case you can use lindex to pass a specific object from the get_selected_objects list to the current_instance command:
current_instance [lindex [get_selected_objects] 0]

Arguments

-primary - (Optional) Indicates that only the primary selected object or objects should be returned; not secondary objects. As a default get_selected_objects will return all currently selected objects.

-quiet - (Optional) Execute the command quietly, returning no messages from the command. The command also returns TCL_OK regardless of any errors encountered during execution.
Note: Any errors encountered on the command-line, while launching the command, will be returned. Only errors occurring inside the command will be trapped.
-verbose - (Optional) Temporarily override any message limits and return all messages from this command.
Note: Message limits can be defined with the set_msg_config command.

Examples

The following example reports the properties of all currently selected objects, both primary and secondary:
report_property [get_selected_objects]