hi,
using github example will help you to build your tool.
using the liquid paint plugin as a base, using the script example to iterate over caches where you can get the function DeformedPolygonCacheIterator

Int the function GetCursorInfo you have to retrieve the object the mouse is over, this can be done with the fuction c4d.utils.ViewportSelect.PickObject and GetPixelInfoPolygon
def GetCursorInfo(self, doc, data, bd, x, y, bc):
xPos = int(x)
yPos = int(y)
vpSelect = c4d.utils.ViewportSelect()
rad = 20
flags = c4d.VIEWPORT_PICK_FLAGS_NONE
# Retrieve the object that are hovered by the mouse
objectsList = c4d.utils.ViewportSelect.PickObject(bd, doc, xPos, yPos, rad, flags)
# Retrieve the frame information, we need the height and width information to initialize the ViewportSelect object.
frame = bd.GetFrame()
width = right - left + 1
height = bottom - top + 1
# Retrieve the object as PolygonObject
polygonObjectList = list()
for op in objectsList:
for cache in self.DeformedPolygonCacheIterator(op):
polygonObjectList.append(cache)
if len(polygonObjectList) < 1:
return True
# Init the viewportSelect object
if not vpSelect.Init(width, height, bd, polygonObjectList, c4d.Mpolyedgepoint, True, c4d.VIEWPORTSELECTFLAGS_IGNORE_HIDDEN_SEL):
return True
# Retrieve the polygon information
infopolygon = vpSelect.GetPixelInfoPolygon(xPos, yPos)
if not infopolygon:
return True
i = infopolygon["i"] # int
op = infopolygon["op"] # c4d.BaseObject
z = infopolygon["z"] # float
# Build the array of the polygon vertices in world coordinates
cpoly = op.GetPolygon(i)
opmg = op.GetMg()
self.pointList = list()
self.pointList.append(op.GetPoint(cpoly.a))
self.pointList.append(op.GetPoint(cpoly.b))
self.pointList.append(op.GetPoint(cpoly.c))
if not cpoly.IsTriangle():
self.pointList.append(op.GetPoint(cpoly.d))
# Transform the local coordinates to world coordinates.
self.pointList = [opmg * p for p in self.pointList]
# Update the view.
c4d.DrawViews(c4d.DA_ONLY_ACTIVE_VIEW | c4d.DA_NO_THREAD | c4d.DA_NO_ANIMATION)
# If the cursor has left a user area, simply return True
if bc.GetId() == c4d.BFM_CURSORINFO_REMOVE:
return True
# Sets the BubbleHelp string and cursor.
bc.SetInt32(c4d.RESULT_CURSOR, c4d.MOUSE_POINT_HAND)
return True
Cheers,
Manuel