This is a script reduced...
For the reference just create file with sphere and set path in script.
--
You received this message because you are subscribed to the Google Groups
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/098a2160-40d6-4876-84a4-deb4e4ead2e3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
# ====================================
# Import Modules
# ====================================
import os
import types
from pymel import core as pmc
from maya import OpenMaya, OpenMayaUI, cmds
# ====================================
# Picker
# ====================================
def func_test():
pmc.createReference(r"FilePath")
class PickerContext(object):
CONTEXT_NAME = "PickerContext"
def __init__(self, func, **kwargs):
"""
!@Brief
@type func: types.FunctionType / types.ClassType
@param func: Function launch if intersect on mesh found
"""
# Context datas
self.__undo_mode = kwargs.get("undoMode", "step")
self.__projection = kwargs.get("projection", "viewPlane")
self.__space = kwargs.get("space", "screen")
self.__cursor = kwargs.get("cursor", "crossHair")
self.__selected_nodes = list()
# CLS
if not isinstance(func, (types.FunctionType, types.ClassType, types.MethodType)):
raise BaseException("Invalid argument given !!!\n\tGive a function or class with matrix for argument...")
self.func = func
def build(self):
"""
@!Brief Build dragger context.
"""
if cmds.draggerContext(self.CONTEXT_NAME, exists=True):
cmds.setToolTo("selectSuperContext")
cmds.selectMode(object=True)
cmds.deleteUI(self.CONTEXT_NAME)
cmds.draggerContext(
self.CONTEXT_NAME,
pressCommand=self.on_press,
name=self.CONTEXT_NAME,
)
def launch(self):
"""
!@Brief Launch picker context.
"""
self.build()
cmds.setToolTo(self.CONTEXT_NAME)
def on_press(self):
"""
!@Brief On press action
"""
self.func()
picker_ctx = PickerContext(func_test)
picker_ctx.launch()