Fair enough :) On 6 April 2016 at 11:46, Marcus Ottosson <[email protected]> wrote:
> There are so many discussions about that already on this list, so I won't > comment on that. > > On 6 April 2016 at 10:39, Ben Hearn <[email protected]> wrote: > >> Thanks for the tips man! >> I have one other question that has been bugging me for some time. >> >> A colleague of mine mentioned he never uses PyMel because cmds sits >> closer to the mel side of things, so I was wondering about speed of >> execution between the two. >> >> From a personal preference I really like PyMel, there are some extra bits >> in there that make life super easy and syntactically pm and cmds are very >> similar. I did some digging about this and the results were always the same >> "its personal preference" >> >> Is there truly any massive speed benefit in using cmds vs pm? >> >> - Ben >> >> On 4 April 2016 at 19:11, Marcus Ottosson <[email protected]> wrote: >> >>> It shouldn’t care much about children, but rather look at the graph as a >>> whole. >>> >>> Here’s an example that works for me, returning an inner child. >>> >>> cmds.file(new=True, force=True) >>> cmds.polyCube(name="myCube1") >>> cmds.polyCube(name="myCube2") >>> cmds.group(name="myGroup")assert "myCube2" in cmds.ls("*2") >>> >>> >>> >>> On 4 April 2016 at 13:45, Ben Hearn <[email protected]> wrote: >>> >>>> Hey Marcus, >>>> >>>> I was wondering about the ls wildcard. I have been trying it out >>>> properly today and it only seems to get the nodes on the top level of the >>>> root, i.e. it will not dig down and give me my inner children. Am I missing >>>> a flag combination, I have tried pretty much all of them and no luck O.o >>>> >>>> Cheers, >>>> >>>> Ben >>>> >>>> On 3 April 2016 at 21:28, Justin Israel <[email protected]> wrote: >>>> >>>>> Hey Ben, >>>>> >>>>> As mentioned, the slowness is because you are comparing a python >>>>> plugin to a C solution. The part of your code that takes the biggest hit >>>>> is >>>>> that while loop. Python is doing so many reflection operations, functions >>>>> calls, and allocations, which is why loops in python will be the killer. >>>>> >>>>> You don't always have to implement your plugins in C. Only when they >>>>> have performance bottlenecks. There are plenty of applications where you >>>>> aren't iterating the scene and doing tons of functions calls and object >>>>> creation. So best to just profile your code and fine the hotspots. Your >>>>> options for slow python plugins are either to write the entire plugin in >>>>> C++ or to just write some speed up utilities for slow operations and call >>>>> them as exposed commands. >>>>> >>>>> I think I even tried writing a simple ls command using Cython a long >>>>> time ago to see if it would work, and it did. That means you could write >>>>> some stuff in Cython >>>>> >>>>> On Mon, 4 Apr 2016 4:54 AM Ben Hearn <[email protected]> wrote: >>>>> >>>>>> From a general plugin development perspective how much work would a >>>>>> general plugin actually do. For example writing an entire tool, would you >>>>>> mix and match with specific bits being a plugin or the entire >>>>>> functionality >>>>>> be wrapped into one plugin? Or as you said would it be more a case by >>>>>> case >>>>>> basis? >>>>>> >>>>>> - Ben >>>>>> >>>>>> On 3 April 2016 at 18:37, Ian Jones <[email protected]> wrote: >>>>>> >>>>>>> I think that's entirely how perf dependant you are. >>>>>>> >>>>>>> We commonly roll new features out unoptimized just to see if the art >>>>>>> team uses them. Many of the tools they don't even bother to ask to make >>>>>>> faster vs getting another tool sooner. Others we spend months optimizing >>>>>>> for the best possible iteration. It's very much a case by case basis. >>>>>>> >>>>>>> Ian >>>>>>> >>>>>>> On Sun, Apr 3, 2016, 9:19 AM Ben Hearn <[email protected]> >>>>>>> wrote: >>>>>>> >>>>>>>> Ah I see, thanks for the tip. So is it advised to port from python >>>>>>>> to C++ when you actually want to roll out the plugin? >>>>>>>> >>>>>>>> On 3 April 2016 at 17:53, Ian Jones <[email protected]> wrote: >>>>>>>> >>>>>>>>> Hey Ben, >>>>>>>>> >>>>>>>>> That's because your plugin is built in Python. The native commands >>>>>>>>> are implemented against the C API which is much faster. Your native >>>>>>>>> example >>>>>>>>> spends less time in python and more in C which is probably why your >>>>>>>>> seeing >>>>>>>>> those results. >>>>>>>>> >>>>>>>>> The good news is it's a relatively straight forward port from >>>>>>>>> Python API to C if your interested. I commonly prototype plugins in >>>>>>>>> Python >>>>>>>>> then port myself if I don't need performance right away. >>>>>>>>> >>>>>>>>> Also if your interested in performance I'd suggest using the >>>>>>>>> profile/cProfile module over time it as it'll help you better >>>>>>>>> understand >>>>>>>>> your code and where the time is spent. >>>>>>>>> >>>>>>>>> Ian >>>>>>>>> >>>>>>>>> On Sun, Apr 3, 2016, 6:14 AM Ben Hearn <[email protected]> >>>>>>>>> wrote: >>>>>>>>> >>>>>>>>>> Aha! I knew I was missing something with ls! >>>>>>>>>> >>>>>>>>>> Thanks for the heads up I have been looking for this for ages. >>>>>>>>>> Still, was good to actually jump into the API :) >>>>>>>>>> >>>>>>>>>> On 3 April 2016 at 15:09, Marcus Ottosson <[email protected] >>>>>>>>>> > wrote: >>>>>>>>>> >>>>>>>>>>> I know the goal isn’t to solve this particular problem, but to >>>>>>>>>>> learn more about the API. But in case you didn’t already know, >>>>>>>>>>> ls with wildcard can do some of this for you. >>>>>>>>>>> >>>>>>>>>>> # Find nodes with prefixcmds.ls("prefix_*") >>>>>>>>>>> # Find nodes with suffixcmds.ls("*_suffix") >>>>>>>>>>> # Find nodes of typecmds.ls(type="locator") >>>>>>>>>>> # Find nodes with suffix, that are children at 2nd level of a >>>>>>>>>>> hierarchycmds.ls("|myParent|*|*_suffix", dag=True) >>>>>>>>>>> >>>>>>>>>>> On 3 April 2016 at 11:54, Benjam901 <[email protected]> >>>>>>>>>>> wrote: >>>>>>>>>>> >>>>>>>>>>> Hello all, >>>>>>>>>>>> >>>>>>>>>>>> I have been digging into the Maya API dungeons recently to get >>>>>>>>>>>> myself up to speed and familiar with the Maya API. >>>>>>>>>>>> >>>>>>>>>>>> I have found myself recently digging through hierarchies to get >>>>>>>>>>>> all nodes of a prefix or of type. I find myself constantly using: >>>>>>>>>>>> >>>>>>>>>>>> for i in pm.listRelatives(object): >>>>>>>>>>>> if i.startswith('prefix'): >>>>>>>>>>>> do stuff... >>>>>>>>>>>> >>>>>>>>>>>> So I decided to write myself a small plugin for a learning task >>>>>>>>>>>> that does this for you. >>>>>>>>>>>> >>>>>>>>>>>> Plugin: >>>>>>>>>>>> https://gist.github.com/ben-hearn-sb/cc5b0ebc5de41fc1f1c937e5b3f3359d >>>>>>>>>>>> >>>>>>>>>>>> The only problem is the speed of the plugin, I put the plugin >>>>>>>>>>>> and the original for i in relatives in 2 functions and used timeit >>>>>>>>>>>> in the >>>>>>>>>>>> maya script editor. >>>>>>>>>>>> The normal list relatives function was faster which seriously >>>>>>>>>>>> confused me because I am sure that the API is supposed to be much >>>>>>>>>>>> faster at >>>>>>>>>>>> processing information, I have a feeling I have some serious >>>>>>>>>>>> inefficiencies >>>>>>>>>>>> in my plugin so any tips would go a long way to help me out! >>>>>>>>>>>> >>>>>>>>>>>> Here is the Maya script editor testing: >>>>>>>>>>>> >>>>>>>>>>>> import maya.cmds as cmds >>>>>>>>>>>> >>>>>>>>>>>> getObjPluginPath = "path to get_objects_under_node.py" >>>>>>>>>>>> >>>>>>>>>>>> cmds.loadPlugin(getObjPluginPath) >>>>>>>>>>>> >>>>>>>>>>>> sel = cmds.ls(sl=True) >>>>>>>>>>>> def pluginWay(): >>>>>>>>>>>> for s in sel: >>>>>>>>>>>> cmds.getObjsUnderNode(s, fn='c_') >>>>>>>>>>>> >>>>>>>>>>>> def normalWay(): >>>>>>>>>>>> for s in sel: >>>>>>>>>>>> myList = [] >>>>>>>>>>>> for i in cmds.listRelatives(s, ad=True, fullPath=True): >>>>>>>>>>>> if i.startswith('c_'): >>>>>>>>>>>> myList.append(i) >>>>>>>>>>>> #print myList >>>>>>>>>>>> >>>>>>>>>>>> import timeit >>>>>>>>>>>> timeit.Timer(pluginWay).timeit(number=500) >>>>>>>>>>>> timeit.Timer(normalWay).timeit(number=500) >>>>>>>>>>>> >>>>>>>>>>>> -- >>>>>>>>>>>> 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/66fc6191-2361-4c99-b954-ea8550863ba2%40googlegroups.com >>>>>>>>>>>> <https://groups.google.com/d/msgid/python_inside_maya/66fc6191-2361-4c99-b954-ea8550863ba2%40googlegroups.com?utm_medium=email&utm_source=footer> >>>>>>>>>>>> . >>>>>>>>>>>> For more options, visit https://groups.google.com/d/optout. >>>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> -- >>>>>>>>>>> *Marcus Ottosson* >>>>>>>>>>> [email protected] >>>>>>>>>>> >>>>>>>>>> -- >>>>>>>>>>> You received this message because you are subscribed to a topic >>>>>>>>>>> in the Google Groups "Python Programming for Autodesk Maya" group. >>>>>>>>>>> To unsubscribe from this topic, visit >>>>>>>>>>> https://groups.google.com/d/topic/python_inside_maya/rnrBzWARs1c/unsubscribe >>>>>>>>>>> . >>>>>>>>>>> To unsubscribe from this group and all its topics, send an email >>>>>>>>>>> to [email protected]. >>>>>>>>>>> >>>>>>>>>> To view this discussion on the web visit >>>>>>>>>>> https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODBFdyk4wKHdNPdNzF_mV%2BstW4AwiRNsjfn_fst4ykB3Q%40mail.gmail.com >>>>>>>>>>> <https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODBFdyk4wKHdNPdNzF_mV%2BstW4AwiRNsjfn_fst4ykB3Q%40mail.gmail.com?utm_medium=email&utm_source=footer> >>>>>>>>>>> . >>>>>>>>>>> >>>>>>>>>>> For more options, visit https://groups.google.com/d/optout. >>>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> -- >>>>>>>>>> >>>>>>>>>> Tel - +46 76245 92 90 (Sweden) >>>>>>>>>> LinkedIn: http://www.linkedin.com/pub/ben-hearn/50/a64/33b >>>>>>>>>> >>>>>>>>>> -- >>>>>>>>>> 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/CAM2ybkXUjewDNSmaD%2Bzr3%2BZr5Ryg8sPnen5nVKa4q06VwQVRKg%40mail.gmail.com >>>>>>>>>> <https://groups.google.com/d/msgid/python_inside_maya/CAM2ybkXUjewDNSmaD%2Bzr3%2BZr5Ryg8sPnen5nVKa4q06VwQVRKg%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 a topic in >>>>>>>>> the Google Groups "Python Programming for Autodesk Maya" group. >>>>>>>>> To unsubscribe from this topic, visit >>>>>>>>> https://groups.google.com/d/topic/python_inside_maya/rnrBzWARs1c/unsubscribe >>>>>>>>> . >>>>>>>>> To unsubscribe from this group and all its topics, send an email >>>>>>>>> to [email protected]. >>>>>>>>> >>>>>>>> To view this discussion on the web visit >>>>>>>>> https://groups.google.com/d/msgid/python_inside_maya/CAL6_5Q_Lq60ZCQ3Hi4vz0EaA85nDCEUrSEZL8dzU1iNTaPazkw%40mail.gmail.com >>>>>>>>> <https://groups.google.com/d/msgid/python_inside_maya/CAL6_5Q_Lq60ZCQ3Hi4vz0EaA85nDCEUrSEZL8dzU1iNTaPazkw%40mail.gmail.com?utm_medium=email&utm_source=footer> >>>>>>>>> . >>>>>>>> >>>>>>>> >>>>>>>>> For more options, visit https://groups.google.com/d/optout. >>>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> -- >>>>>>>> >>>>>>>> Tel - +46 76245 92 90 (Sweden) >>>>>>>> LinkedIn: http://www.linkedin.com/pub/ben-hearn/50/a64/33b >>>>>>>> >>>>>>>> -- >>>>>>>> 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/CAM2ybkUOHgTwjNgN%3DRApagUwF%2BfT_gaQ%2BpSmNeT%2B3yuudw6toQ%40mail.gmail.com >>>>>>>> <https://groups.google.com/d/msgid/python_inside_maya/CAM2ybkUOHgTwjNgN%3DRApagUwF%2BfT_gaQ%2BpSmNeT%2B3yuudw6toQ%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 a topic in >>>>>>> the Google Groups "Python Programming for Autodesk Maya" group. >>>>>>> To unsubscribe from this topic, visit >>>>>>> https://groups.google.com/d/topic/python_inside_maya/rnrBzWARs1c/unsubscribe >>>>>>> . >>>>>>> To unsubscribe from this group and all its topics, send an email to >>>>>>> [email protected]. >>>>>>> >>>>>> To view this discussion on the web visit >>>>>>> https://groups.google.com/d/msgid/python_inside_maya/CAL6_5Q9LXL9ibararTHOgHki5Wn_k04BP3QDXiLL_nu-BVFdXQ%40mail.gmail.com >>>>>>> <https://groups.google.com/d/msgid/python_inside_maya/CAL6_5Q9LXL9ibararTHOgHki5Wn_k04BP3QDXiLL_nu-BVFdXQ%40mail.gmail.com?utm_medium=email&utm_source=footer> >>>>>>> . >>>>>>> >>>>>>> For more options, visit https://groups.google.com/d/optout. >>>>>>> >>>>>> >>>>>> -- >>>>>> >>>>>> Tel - +46 76245 92 90 (Sweden) >>>>>> LinkedIn: http://www.linkedin.com/pub/ben-hearn/50/a64/33b >>>>>> >>>>>> -- >>>>>> 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/CAM2ybkU-Fs3-1OHohtUKKOCjqSP1tOCJcYxSiFF4WsGK%3D7KG3g%40mail.gmail.com >>>>>> <https://groups.google.com/d/msgid/python_inside_maya/CAM2ybkU-Fs3-1OHohtUKKOCjqSP1tOCJcYxSiFF4WsGK%3D7KG3g%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 a topic in the >>>>> Google Groups "Python Programming for Autodesk Maya" group. >>>>> To unsubscribe from this topic, visit >>>>> https://groups.google.com/d/topic/python_inside_maya/rnrBzWARs1c/unsubscribe >>>>> . >>>>> To unsubscribe from this group and all its topics, send an email to >>>>> [email protected]. >>>>> To view this discussion on the web visit >>>>> https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0mBNiAKDE6MEnNi6gJn7RZCObYY7GsJHAd_rK2YHWQFA%40mail.gmail.com >>>>> <https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0mBNiAKDE6MEnNi6gJn7RZCObYY7GsJHAd_rK2YHWQFA%40mail.gmail.com?utm_medium=email&utm_source=footer> >>>>> . >>>>> >>>>> For more options, visit https://groups.google.com/d/optout. >>>>> >>>> >>>> >>>> >>>> -- >>>> >>>> Tel - +46 76245 92 90 (Sweden) >>>> LinkedIn: http://www.linkedin.com/pub/ben-hearn/50/a64/33b >>>> >>>> -- >>>> 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/CAM2ybkXibqPwPD9%3DBrEeKf7zargxw%2BtvBN-6CYy1ZBfuJm7s0A%40mail.gmail.com >>>> <https://groups.google.com/d/msgid/python_inside_maya/CAM2ybkXibqPwPD9%3DBrEeKf7zargxw%2BtvBN-6CYy1ZBfuJm7s0A%40mail.gmail.com?utm_medium=email&utm_source=footer> >>>> . >>>> >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> >>> >>> >>> -- >>> *Marcus Ottosson* >>> [email protected] >>> >>> -- >>> You received this message because you are subscribed to a topic in the >>> Google Groups "Python Programming for Autodesk Maya" group. >>> To unsubscribe from this topic, visit >>> https://groups.google.com/d/topic/python_inside_maya/rnrBzWARs1c/unsubscribe >>> . >>> To unsubscribe from this group and all its topics, send an email to >>> [email protected]. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOBLkEaeBoJG%2Bn_VLchywxkOEmTcGBUw1%2BgS0bYm-OH1eg%40mail.gmail.com >>> <https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOBLkEaeBoJG%2Bn_VLchywxkOEmTcGBUw1%2BgS0bYm-OH1eg%40mail.gmail.com?utm_medium=email&utm_source=footer> >>> . >>> >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> >> >> -- >> >> Tel - +46 76245 92 90 (Sweden) >> LinkedIn: http://www.linkedin.com/pub/ben-hearn/50/a64/33b >> >> -- >> 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/CAM2ybkX3NO1yRfdXgVvfcGxxyC0Vah%2By%2B1ahCqfKePe7G0NHWA%40mail.gmail.com >> <https://groups.google.com/d/msgid/python_inside_maya/CAM2ybkX3NO1yRfdXgVvfcGxxyC0Vah%2By%2B1ahCqfKePe7G0NHWA%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > *Marcus Ottosson* > [email protected] > > -- > You received this message because you are subscribed to a topic in the > Google Groups "Python Programming for Autodesk Maya" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/python_inside_maya/rnrBzWARs1c/unsubscribe > . > To unsubscribe from this group and all its topics, send an email to > [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOCyoCkFc%2BEaVFN60wu%2BE%2BkYZMRsD7gWszsi-z1E0Ayy6g%40mail.gmail.com > <https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOCyoCkFc%2BEaVFN60wu%2BE%2BkYZMRsD7gWszsi-z1E0Ayy6g%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- Tel - +46 76245 92 90 (Sweden) LinkedIn: http://www.linkedin.com/pub/ben-hearn/50/a64/33b -- 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/CAM2ybkXAvJkih7zw-s2RpOBna3BfyCpedv%3DQxPpqhEBexgDwZg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
