--
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_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/3f87dcf5-3171-47e7-bec5-a56d550513d1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
On Thu, May 2, 2019, 9:24 PM Zhen Huang <qeej...@gmail.com> wrote:Hi ,I have a question about python build-in function 'eval ' , please check out the example code below :## create a polySphere , default name : 'pSphere1'import pymel.core as pmfrom pymel.core import nt# initialize a pymel transform nodepymelShpere = pm.PyNode('pSphere1')# put it to a dicttestDict = {0:pymelShpere}# convert it to str which can be stored as string in file basic datastrMark = str(testDict)# now read it back , if scene has the pShere1 , it will work perfectlynewDict = eval(strMark)# now delete the pShpere1 , and try to convert data to dict , failed because the pymel nt will try to initialize the string 'pShere1' to pymel nodenewDict =eval(strMark)My question : if I have lots of nodes store in a string data which convert from dict , is there a way to just make it out , just ignore error part or if node not exists it just convert from nt to string name ?if pSphere2 not exist then return{0:nt.Transform('pSphere1'), 1:'pSphere2' }Any idea is very much welcome , big thanks !!!I would advise staying away from the eval() approach. Not only is it going to be inflexible for your current goal, it also can cause unwanted execution of arbitrary logic. A random code snippet that deletes files could be set on a node and your code would blindly execute it as your own user. You don't want random code being evaluated like that.A better approach would be to use a proper serialisation format like json or pickle (protocol version 1 for ascii format). This would allow you to read the data back into a dictionary and then evaluate each value and filter what does and does not exist in the scene.
--
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.
Hi Justin ,Thank you ! I've tried the json even can't dumps the pymel node data . This is why I looked for the eval solution .Please check the error out :Error: TypeError: file C:\Program Files\Autodesk\Maya2017\bin\python27.zip\json\encoder.py line 184: nt.Transform(u'pSphere2') is not JSON serializableThanks and Regards ,
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/3f87dcf5-3171-47e7-bec5-a56d550513d1%40googlegroups.com.
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_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/09731b94-8047-4136-bd12-a66781210224%40googlegroups.com.
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/3f87dcf5-3171-47e7-bec5-a56d550513d1%40googlegroups.com.
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+unsub...@googlegroups.com.
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/3f87dcf5-3171-47e7-bec5-a56d550513d1%40googlegroups.com.
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+unsub...@googlegroups.com.
Hi Justin ,cPickle can deserialize pymel node , and like eval it can't convert back if the node not exists .Thank you ,
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/3f87dcf5-3171-47e7-bec5-a56d550513d1%40googlegroups.com.
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_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/09731b94-8047-4136-bd12-a66781210224%40googlegroups.com.
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_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/70ea3488-20ed-4926-baf3-6e19de71e479%40googlegroups.com.
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/3f87dcf5-3171-47e7-bec5-a56d550513d1%40googlegroups.com.
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+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/09731b94-8047-4136-bd12-a66781210224%40googlegroups.com.
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+unsub...@googlegroups.com.
--
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_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/3f87dcf5-3171-47e7-bec5-a56d550513d1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I'm not sure what your end goal is. But if it's just to get whats in the dictionary, use the iteritems dictionary method.dict = {'A': 'sphere1', 'B': 'sphere2'}for key, val in dict.iteritems():
print key, valI tested it with the value being a pymel class object and it works too.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAKjYKQkJQB%3D2e3JX0jtcjoQN0xcy41ELn0%2BVnYnhEvWYUi0OXg%40mail.gmail.com.
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/3f87dcf5-3171-47e7-bec5-a56d550513d1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
----Alon ZaslavskyPuppet TD
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.
Yes , converting to string before storing in file will absolutely no problem , what I except is there any solution to intervene the reading process .For example if we use cPickle , maybe we can create monkey patch for the cPickle.load function . Let reading process running without raising any error for pymel node.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/3f87dcf5-3171-47e7-bec5-a56d550513d1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
----Alon ZaslavskyPuppet TD
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_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAKjYKQkJQB%3D2e3JX0jtcjoQN0xcy41ELn0%2BVnYnhEvWYUi0OXg%40mail.gmail.com.
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_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/fdbc67c6-43c4-41a1-bb73-277e2d7ce368%40googlegroups.com.
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/3f87dcf5-3171-47e7-bec5-a56d550513d1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
----Alon ZaslavskyPuppet TD
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/CAKjYKQkJQB%3D2e3JX0jtcjoQN0xcy41ELn0%2BVnYnhEvWYUi0OXg%40mail.gmail.com.
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+unsub...@googlegroups.com.