Hi,
You can do it in the same way, but first you need set odb file from current viewport to a variable.
from abaqus import session
#
# find current viewport
currentViewport = session.viewports[session.currentViewportName]
# assign odb file from current viewport
odbFile = currentViewport.displayedObject
# get file name and path
odbFileNameFull = odbFile.path
#split into separately name and path
odbFileName = os.path.split(odbFileNameFull)[1]
odbPath = os.path.split(odbFileNameFull)[0]
Regards,
akaBarten