--
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 python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/44516db8-e6b7-4a52-817b-aea2f254da44%40googlegroups.com.
Even with a code reduced to the maximum I have the same problem when I load a reference with the DraggerContext.If I create an object in script I do not have this problem.
--
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 python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/c4d90708-3e8e-4e98-9f16-a40d0961c4c6%40googlegroups.com.
Ok, when I change the trigger from pressCommand to releaseCommand it works for me.
The reason I think, is because when you press you put Maya in a suspended mode. Awaiting a release. During the release it would resume normal duties like updating the GUI and viewport. But, because you create a reference while being pressed, you prevent Maya from detecting a release. As though you were erasing its memory of anything being pressed. That could explain why you would have to forcefully refresh Maya after exiting the context.
Full example.
import types
from maya import cmds
def func_test():
nodes = cmds.file("scenes/temp.ma", reference=True, returnNewNodes=True)
cmds.select(nodes)
class PickerContext(object):
CONTEXT_NAME = "PickerContext"
def __init__(self, func, **kwargs):
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()
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):
if cmds.draggerContext(self.CONTEXT_NAME, exists=True):
cmds.setToolTo("selectSuperContext")
cmds.selectMode(object=True)
cmds.deleteUI("PickerContext")
cmds.draggerContext(
self.CONTEXT_NAME,
releaseCommand=self.on_press,
name=self.CONTEXT_NAME,
)
def launch(self):
self.build()
cmds.setToolTo(self.CONTEXT_NAME)
def on_press(self):
self.func()
# Create a reference
cmds.file(new=True, force=True)
cmds.polyCube()
cmds.file(rename="temp.ma")
cmds.file(save=True, force=True)
cmds.file(new=True, force=True)
# Pick
cmds.sphere(radius=0.5)
picker_ctx = PickerContext(func_test)
picker_ctx.launch()
--
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 python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/3659c450-477b-4ca5-aa7e-11cf9e4b5fbf%40googlegroups.com.
OH sh** it's works... I never thought of that !Thank you very much Marcus !!!
--
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 python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/1f159c5b-49e9-42a6-899b-4be40b75d51c%40googlegroups.com.