hitTest()
注意: オブジェクト名や引数を表す文字列はカンマで区切ります。これは概要には示されていません。
hitTest は 「元に戻す」が不可能、「照会」が不可能、「編集」が不可能 です。
hitTest コマンドは、指定したコントロール内のポイントをヒット テストし、ポイントの下にある項目のリストを返します。ポイントは左上隅を原点(0,0)とし、ピクセルで指定されます。この位置は、ドロップ コールバックの座標と互換性があります。返される項目のタイプは、特定のコントロールに依存します。現在、ヒット テストはすべてのコントロールによってサポートされていません。string[] | ヒットしたポイントの下の項目 |
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 = cmds.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 = cmds.editor( editor ,query=True, control=True ) if cmds.control( control, exists=True ): cmds.control( control, edit=True, dropCallback=myModelEditorDropCallback ) except RuntimeError: pass