getObjectBySelection#

FDTD.getObjectBySelection()#

Returns the currently selected simulation object, if multiple objects are selected, the first one in the list returned.

Parameters:
None
Returns:
ansys.lumerical.core.SimObject

Object obtained by function.

See also

getObjectById()

Returns a simulation object by ID.

getAllSelectedObjects()

Returns a list of all currently selected simulation objects

Examples

>>> fdtd = lumapi.FDTD()
>>> z_placements = [0, 1e-6, 2e-6, 3e-6]
>>> for i,position in enumerate(z_placements):
>>>     fdtd.addrect(name = f"Rect{i}", z=position)
>>> fdtd.selectpartial("Rect") #Selects all objects with “Rect” as a part of its name
>>> obj = fdtd.getObjectBySelection() #Only the first one out of the objects that are selected is returned here
>>> print(f"Rectangle name: {obj['name']}, z position: {obj['z']} 

Returns

>>> Rectangle name: Rect0, z position: 0.0