Jump to content

Use a point monitor to add items to the hover tooltip


Recommended Posts

Posted (edited)

[Advanced] Use a point monitor to add items to the hover tooltip

 

import traceback
from pyrx import Rx, Ge, Gi, Db, Ap, Ed

print("added command pymon")
print("added command pyunmon")

# Adds the monitors to the application
def OnPyInitApp():
    PyRxCmd_pymon()

def OnPyUnloadApp():
    PyRxCmd_pyunmon()

# https://help.autodesk.com/view/OARX/2025/ENU/?guid=GUID-BBDA79D3-A509-4C96-966E-72592BD32ACD
class MyPointMonitor(Ed.InputPointMonitor):
    def __init__(self):
        Ed.InputPointMonitor.__init__(self)

    def monitorInputPoint(self, input: Ed.InputPoint, output: Ed.InputPointMonitorResult):
        try:
            ents = input.pickedEntities()
            geo: Gi.Geometry = input.drawContext().geometry()

            if len(ents) == 0:
                geo.text(input.rawPoint(), Ge.Vector3d.kZAxis, Ge.Vector3d.kXAxis, 10.0, 1.0, 0, "Cold")
                output.setAdditionalTooltipString("COLD")
            else:
                geo.text(input.rawPoint(), Ge.Vector3d.kZAxis, Ge.Vector3d.kXAxis, 10.0, 1.0, 0, "Hot")
                output.setAdditionalTooltipString("HOT")

        except Exception as err:
            print(err)


# global space
pm = MyPointMonitor()


def PyRxCmd_pymon():
    try:
        manager = Ap.curDoc().inputPointManager()
        manager.addPointMonitor(pm)
    except Exception as err:
        print(err)


def PyRxCmd_pyunmon():
    try:
        manager = Ap.curDoc().inputPointManager()
        manager.removePointMonitor(pm)
    except Exception as err:
        print(err)

 

 

Edited by Danielm103
  • Like 2
Posted

sorry the screenshot is wonky, working on it

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...