pymel.core.system.hitTest

hitTest(*args, **kwargs)

The hitTestcommand hit-tests a point in the named control and returns a list of items underneath the point. The point is specified in pixels with the origin (0,0) at the top-left corner. This position is compatible with the coordinates provided by a drop-callback. The types of items that may be returned depends upon the specific control; not all controls currently support hit-testing.

Derived from mel command maya.cmds.hitTest

Example:

import pymel.core as pm

import maya.cmds as cmds

#    Let's say that you have the name of a model editor that was
#    created elsewhere.
#
editor = "MyModelEditor"
#    Here's your drop callback:
#
def myModelEditorDropCallback( dragControl,
                                                           dropControl,
                                                           msgs,
                                                           x,
                                                           y,
                                                           type ):
        #       Inside the callback we can hit-test the (x,y) drop-point
        #       against the control. This will return a list of DAG objects
        #       underneath the drop-point.
        #
        objects = pm.hitTest( dropControl, x, y )
        if len( objects ):
                #       The hit-test returned something. You can now do something
                #       with these objects.
                pass
#
#       Attach a drop callback to this model editor.
#
try:
        control = pm.editor( editor ,query=True, control=True )
        if pm.control( control, exists=True ):
                pm.control( control, edit=True, dropCallback=myModelEditorDropCallback )
except RuntimeError:
        pass

Previous topic

pymel.core.system.hardware

Next topic

pymel.core.system.imfPlugins

Core

Core Modules

Other Modules

This Page