On Sat, Apr 30, 2016 at 7:30 AM Tom Norman <[email protected]> wrote:
> A scriptjob is better if you need to catch attribute changed for a > specific attribute (translateX in this case). > > If you need to code to run when ANY attribute of a node changes, the API > callback is the better bet. (Single callback vs. a scriptjob for each > settable attribute of the node) > That would make sense, yea. If the scriptJob ends up doing the routing and filtering of the message on the C++ side and delivering it to your python callback only after it fully matches, then that would reduce the python overhead. > > > On Friday, 29 April 2016 10:19:35 UTC-4, ynedelin wrote: > >> I was just wondering how will this method compare to build- in scriptJob. >> > On Apr 29, 2016 4:38 AM, "Justin Israel" <[email protected]> wrote: >> >>> >>> >>> On Fri, 29 Apr 2016 3:39 PM yury nedelin <[email protected]> wrote: >>> >>>> Is this better then a scriptJob? >>>> Yury >>>> >>> >>> isn't a scriptJob the same thing (the c++ API being exposed to >>> mel/python) >>> >>> Unless maybe you are suggesting that a Mel callback might have less >>> overhead? >>> >>> >>>> On Thu, Apr 28, 2016 at 2:06 PM, Justin Israel <[email protected]> >>>> wrote: >>>> >>> Out of curiosity, what are the performance numbers like when your >>>>> callback simply does nothing and passes? I am wondering if the required >>>>> checks in your function body are slow, or if simply using a python-based >>>>> callback is the slow part in the first place. >>>>> >>>>> Justin >>>>> >>>>> >>>>> On Fri, Apr 29, 2016 at 8:25 AM Marcus Ottosson <[email protected]> >>>>> wrote: >>>>> >>>> Hi all, >>>>>> >>>>>> I’ve managed to devise a method of listening in on an attribute >>>>>> changing, so I can respond appropriately. But I’m interested in whether >>>>>> there’s a more efficient way. Efficiency is my main concern in this case. >>>>>> >>>>>> import osimport timefrom maya import cmds, OpenMaya as om >>>>>> # Setup scene >>>>>> cmds.file(new=True, force=True) >>>>>> cmds.polyCube() >>>>>> # Find cube as MObject# Is this the optimal route? >>>>>> dag_path = om.MDagPath() >>>>>> selection = om.MSelectionList() >>>>>> selection.add("pCube1") >>>>>> selection.getDagPath(0, dag_path) >>>>>> m_obj = dag_path.node() >>>>>> # Callback listening to changes to ANY attribute# Is this efficient?def >>>>>> callback(message_type, plug, other_plug, client_data): >>>>>> if not message_type & om.MNodeMessage.kAttributeSet: >>>>>> return >>>>>> >>>>>> if "translateX" in plug.name(): >>>>>> print("Translate X changed!") >>>>>> >>>>>> job = om.MNodeMessage.addAttributeChangedCallback(m_obj, >>>>>> callback)#om.MMessage.removeCallback(job) >>>>>> >>>>>> The obvious issue is how I’m listening for changes on *any* >>>>>> attribute change, rather than just the one I’m interested in, and then >>>>>> filtering it down. The Python callback is triggered a few more times than >>>>>> I’d like. >>>>>> >>>>>> In an empty scene, without this callback, Maya is running at >>>>>> 1200-1300 fps (0.8ms/frame) whereas with this callback it’s running >>>>>> closer >>>>>> to 400 (2.5ms/frame). >>>>>> >>>>>> Any ideas? >>>>>> >>>>>> Best, >>>>>> Marcus >>>>>> >>>>>> >>>>> -- >>>>>> *Marcus Ottosson* >>>>>> [email protected] >>>>>> >>>>> -- >>>>>> 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/CAFRtmOBppomMtcXWQvayoC07ht658JB2H5uZVWtnxcyHWrYynw%40mail.gmail.com >>>>>> <https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOBppomMtcXWQvayoC07ht658JB2H5uZVWtnxcyHWrYynw%40mail.gmail.com?utm_medium=email&utm_source=footer> >>>>>> . >>>>>> For more options, visit https://groups.google.com/d/optout. >>>>>> >>>>> -- >>>>> 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/CAPGFgA2O%2Bpsyf37MdKVm6P6sGkNcsGD6hBHfNGC-6yRDJ6xK4A%40mail.gmail.com >>>>> <https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA2O%2Bpsyf37MdKVm6P6sGkNcsGD6hBHfNGC-6yRDJ6xK4A%40mail.gmail.com?utm_medium=email&utm_source=footer> >>>>> . >>>> >>>> >>>>> For more options, visit https://groups.google.com/d/optout. >>>>> >>>> -- >>>> 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/CACqGScgm_ZV8YLgaMHy3%3Dach1bA3YQq6bCWVyGTSE7hLdRzS0g%40mail.gmail.com >>>> <https://groups.google.com/d/msgid/python_inside_maya/CACqGScgm_ZV8YLgaMHy3%3Dach1bA3YQq6bCWVyGTSE7hLdRzS0g%40mail.gmail.com?utm_medium=email&utm_source=footer> >>>> . >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> -- >>> 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/CAPGFgA2MGV5ub16BaoRrAzgxs%3DYQypae3xfTVxbmPSUVgsvpcA%40mail.gmail.com >>> <https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA2MGV5ub16BaoRrAzgxs%3DYQypae3xfTVxbmPSUVgsvpcA%40mail.gmail.com?utm_medium=email&utm_source=footer> >>> . >>> For more options, visit https://groups.google.com/d/optout. >>> >> -- > 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/b634aad2-de3f-4845-9d47-363ef5458eb5%40googlegroups.com > <https://groups.google.com/d/msgid/python_inside_maya/b634aad2-de3f-4845-9d47-363ef5458eb5%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- 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/CAPGFgA1bMKGj6FGX2yT9oxJjaPSPisGQeS3ceKE__fSjyx2USQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
