You should just test both approaches and find out if the performance difference is acceptable. In a recent thread on this group, there was an example of creating many pynodes vs using cmds. At lower numbers you may not perceive a difference. At higher numbers it could be seconds vs subseconds
On Thu, 12 Mar 2015 4:08 PM Panupat Chongstitwattana <panup...@gmail.com> wrote: > Thank you every one. > > The current script I trying this is about retrieving hundreds or even > thousands of names from Json/SQL and adjust maybe 1 or 2 attributes of > each. Looping through strings creating PyNode over and over only to perform > 1 operation... would this bother you or do you think it shouldn't matter? I > get a feeling PyMel maybe more suitable for scripts that manipulate fewer > number of objects where you're adjusting many attributes. > > > > On Thursday, March 12, 2015 at 12:44:54 AM UTC+7, Geordie Martinez wrote: > >> If you'd like to learn more about pymel this is a great book. >> check out Practical Maya Programming with Python: >> http://www.amazon.com/Practical-Programming-Python-Robert-Galanakis/dp/ >> 1849694729/ref=sr_1_1?ie=UTF8&qid=1426095687&sr=8-1& >> keywords=practical+maya+programming+with+python >> >> and I hear these videos are okay ;) (shameless plug) >> http://www.cgcircuit.com/course/intro-to-pymel-part-1 >> >> >> >> >> >> On Wed, Mar 11, 2015 at 6:21 AM, Paul Molodowitch <elro...@gmail.com> >> wrote: >> > From a functional standpoint, there isn't a difference. There may be a >>> performance difference, but unless you're making thousands, I wouldn't >>> worry about it. >>> >>> Generally speaking, if I usually expect it to exist, and want to use it >>> as a PyNode if it does, I'll do the try/except thing. One note though - >>> you should probably do: >>> >>> try: >>> pmc.PyNode(string) >>> except pmc.MayaNodeError: >>> print "something" >>> >>> It's bad practice to have blanket except statements** - particularly if >>> you're "expecting" a certain type of error. Get in the habit of having >>> targeted try excepts, and you'll save yourself from headaches down the road. >>> >>> - Paul >>> >>> **There are always exceptions, of course - for instance, if you're >>> running an app and don't want an unknown error to bring everything to a >>> halt, it can make sense to have some generic high-level try/except >>> statements. And in those cases, you'll probably want to at least print >>> some sort of warning or traceback, or maybe log it to an error log, or >>> email a bug report, etc. Also, even then, it's better to do "except >>> Exception as e:" or "except Exception:" instead of "except:", because the >>> latter will catch strange things you almost certainly don't want to - ie, >>> if the user presses ctrl-c, or even if you've explicitly tried to call >>> sys.exit! >>> >>> >>> On Wed, Mar 11, 2015 at 12:32 AM, Panupat Chongstitwattana < >>> panu...@gmail.com> wrote: >>> >>>> Ah thank you. Such a silly mistake :( >>>> >>>> Is there any draw back if I don't check objExists but instead go for >>>> this? >>>> >>>> try: >>>> PyNode(string) >>>> except: >>>> print "something" >>>> >>>> >>>> >>>> On Wednesday, March 11, 2015 at 2:02:06 PM UTC+7, Justin Israel wrote: >>>>> >>>>> You have a typo between the two ways you format the string : >>>>> >>>>> tmpname = "%smaster_crtl" % sel.namespace() >>>>> tmp = "%smaster_ctrl" % selects[0].namespace() >>>>> >>>>> crtl vs ctrl >>>>> >>>>> On Wed, 11 Mar 2015 7:02 PM Panupat Chongstitwattana < >>>>> panu...@gmail.com> wrote: >>>>> >>>>>> Hi. >>>>>> >>>>>> I ran into another problem. objExists is returning different result >>>>>> when I put it in a for loop. >>>>>> >>>>>> selects = pmc.selected() >>>>>> >>>>>> for sel in selects: >>>>>> tmpname = "%smaster_crtl" % sel.namespace() >>>>>> print tmpname >>>>>> print pmc.objExists(tmpname) >>>>>> # SC05A_0110_ECh_LoopAnim_v002:SC05A_0020_Extra_Cheer_LoopAnim >>>>>> _v001:exMaleHair001:master_ctrl >>>>>> # False >>>>>> >>>>>> tmp = "%smaster_ctrl" % selects[0].namespace() >>>>>> print tmp >>>>>> print pmc.objExists(tmp) >>>>>> # SC05A_0110_ECh_LoopAnim_v002:SC05A_0020_Extra_Cheer_LoopAnim >>>>>> _v001:exMaleHair001:master_ctrl >>>>>> # True >>>>>> >>>>>> What could be the cause of this? >>>>>> >>>>>> >>>>>> -- >>>> >>> -- > 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+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/python_inside_maya/1e01a0a8-fdb0-4af8-92c9-c8580c9ff862%40googlegroups.com > <https://groups.google.com/d/msgid/python_inside_maya/1e01a0a8-fdb0-4af8-92c9-c8580c9ff862%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 python_inside_maya+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA3dsGM32RbFroHmWE%2B4HeEeM_rEcEqVPG2OBd2TPh3jFw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.