Issue with salome.IDToObject

Hello,

i have been using `obj=salome.IDToObject(salome.sg.getSelected(0))` for the past few years in geom with my scripts, i just noticed that if i open salome, open a hdf with geom, but not open geom but shaper, then open geom, select two objects and use:

obj=salome.IDToObject(salome.sg.getSelected(0))
obj=salome.IDToObject(salome.sg.getSelected(1))

I get an error:

SalomeOutsideGUI: no selection mechanism available outside GUI
SalomeOutsideGUI: no selection mechanism available outside GUI

is this a normal behavior? should i use another approach?