DraggerContext disable outliner refresh...

165 views
Skip to first unread message

Rémi Deletrain

unread,
Feb 24, 2017, 4:06:09 AM2/24/17
to Python Programming for Autodesk Maya
Hi everybody, I've problem with the DraggerContext and Maya 2014. I create a picker that allows you to position an object in position and rotate on a mesh. This part works very well. My problem is that the outliner does not update when I do my picking or when I leave the tool. I am forced to make a selection in the viewport to update it. The command refresh or select does not change anything. Does anyone know of this problem and has it settled?

justin hidair

unread,
Feb 25, 2017, 3:02:27 AM2/25/17
to Python Programming for Autodesk Maya
Tu parles français? if not, can you explain the problem in detail, not sure I understand

Rémi Deletrain

unread,
Feb 27, 2017, 4:18:29 AM2/27/17
to Python Programming for Autodesk Maya
Oui je parle français. Je re explique en français du coup...

J'ai fait un picker qui permet de positionner un objet sur un mesh et de l'orienter par rapport à la normal.
Cette partie de l'outil fonctionne très bien.

J'utilise pour ça le draggerContext. Le problème c'est que dès que je lance le DraggerContext et que je pick sur un objet l'affichage ne se met pas à jour.
Pour le viewport je force le refresh dans la fonction mais l'outliner lui reste figé...
Il se remet en route uniquement quand je quitte le DraggerContext et que je sélectionne un objet à la main.

================================================================================================================


I made a picker that allows to position an object on a mesh and orient it with the normal. This part of the tool works very well. I use the draggerContext for that. The problem is that as soon as I launch the DraggerContext and I pick on an object the display does not update. For the viewport I force the refresh in the function but the outliner remains frozen to him ... It starts again only when I leave the DraggerContext and I select an object by hand.

Marcus Ottosson

unread,
Feb 27, 2017, 4:19:49 AM2/27/17
to python_in...@googlegroups.com
Hi Remi, would it be possible to post an example? It would simplify seeing the problem first-hand and may give you a quicker answer with solution.

--
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.

For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

Rémi Deletrain

unread,
Feb 27, 2017, 4:53:16 AM2/27/17
to Python Programming for Autodesk Maya
it's difficult to give an explicit exemple by image.

With the file I attached. We see that there is a lot of small sphere. this sphere appear as soon as I click in the viewport on a mesh. The problem is that the outliner does not refresh and does not display my new spheres ...
picker_problem.jpg

Marcus Ottosson

unread,
Feb 27, 2017, 5:07:01 AM2/27/17
to python_in...@googlegroups.com
It would be better if you could post the code that reproduces the problem, such that I could run it on my computer and see exactly what you mean.​

Rémi Deletrain

unread,
Feb 27, 2017, 6:00:34 AM2/27/17
to Python Programming for Autodesk Maya
This is my script. This is not the final version it is still in dev so it's normal if some thing looks odd. I had to overwrite all the dependencies so that it works in one file. I just noticed one thing. The I add a sphere in script on this code. But the object I add in the scene is normally a reference. So the refresh works with an object add in code but not in reference ...
picker_test.py

Marcus Ottosson

unread,
Feb 27, 2017, 6:35:10 AM2/27/17
to python_in...@googlegroups.com
Thanks, that's perfect. Here's what I would suggest - try removing as many lines as possible from this snipped without removing the problem. It will help you to narrow down exactly where the problem lies, and us in understanding what we're looking at.

Rémi Deletrain

unread,
Feb 27, 2017, 6:39:31 AM2/27/17
to Python Programming for Autodesk Maya
Thanks Marcus,

I try this this afternoon.
For this moment I think the problem is when I loading my reference with the DraggerContext...

Rémi Deletrain

unread,
Feb 27, 2017, 6:58:53 AM2/27/17
to Python Programming for Autodesk Maya
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.


Marcus Ottosson

unread,
Feb 27, 2017, 7:02:58 AM2/27/17
to python_in...@googlegroups.com
Excellent, post the maximum reduced problem and I can try and take a look.

On 27 February 2017 at 11:58, Rémi Deletrain <remi.de...@gmail.com> wrote:
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.

For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

Rémi Deletrain

unread,
Feb 27, 2017, 7:18:06 AM2/27/17
to Python Programming for Autodesk Maya
This is a script reduced...
For the reference just create file with sphere and set path in script.
picker_test_reduced.py

justin hidair

unread,
Feb 27, 2017, 10:21:25 PM2/27/17
to Python Programming for Autodesk Maya
C'est vrai que c'est bizarre , n' y a -t-il pas une method qui update l'outliner (dans MGlobal il y a plein de petites choses why not) ? je suis sans indices, car j'ai jamais eu à faire à ça...

Rémi Deletrain

unread,
Feb 28, 2017, 4:05:11 AM2/28/17
to Python Programming for Autodesk Maya
Je n'ai rien trouvé jusqu'à présent pour faire un refresh de l'outliner.
J'ai essayé de forcer les sélections dans le code pour remettre à jour (car après avoir quitter le DraggerContext il n'y a que ça qui fait le refresh) mais ça ne change rien non plus..

=================================================================================================================================================

I have not found anything to make a refresh of the outliner.
I tried to force the selections in the code to update (because after leaving the DraggerContext there is only that which makes the refresh) but it does not change either ...

Marcus Ottosson

unread,
Feb 28, 2017, 4:37:17 AM2/28/17
to python_in...@googlegroups.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.

For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

Rémi Deletrain

unread,
Feb 28, 2017, 4:58:59 AM2/28/17
to Python Programming for Autodesk Maya
OH sh** it's works... I never thought of that !
Thank you very much Marcus !!!

Marcus Ottosson

unread,
Feb 28, 2017, 9:55:41 AM2/28/17
to python_in...@googlegroups.com
No problem, Remi. Glad to help.

On 28 February 2017 at 09:58, Rémi Deletrain <remi.de...@gmail.com> wrote:
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.

For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

Reply all
Reply to author
Forward
0 new messages