Get cacheName and cachePath attributes from a selected object

Hello,
Anybody knows how could I get the cacheName and cachePath from a selected object in Python?

Thanks!

I've tried this and it gives me those attributes:

import maya.cmds as cmds

myPath = cmds.getAttr('pCylinderShape1Cache1.cachePath')

myName = cmds.getAttr('pCylinderShape1Cache1.cacheName')

But now what I need is a way to get the cache node name ('pCylinderShape1Cache1' in this case) from the selected object.

Thanks!

cmds.ls( cmds.listHistory(transformOrShapeName), et='cacheFile')

fill in transformOrShapeName, or just skip it alltogether if your using the base selection list. So for example to make a dictionary of all selected objects with cache you could do:

dict([(item, cmds.ls(cmds.listHistory(item), et='cacheFile')[0]) for item in cmds.ls(selection=1) if len(cmds.ls(cmds.listHistory(item), et='cacheFile')) ] )

ajuts a word of warning shapes may have many caches.

Awesome! Thanks a lot!