On Thursday, June 20, 2019 at 2:43:28 AM UTC+2, yann19 wrote: > I am trying to query for the default expression used in the imagePlane with > the following code: > > > > > > # Part01 > img = cmds.imagePlane() > frame_ext_attr = "{0}.useFrameExtension".format(img[0]) > cmds.setAttr(frame_ext_attr, True) > > > # Part02 > print '>>> ', cmds.listConnections("{0}.frameExtension".format(img[0])) > If I am running the above code block as a whole, the return result in > `Part02` is `None`. > However, if I run them in 2 parts, `Part02` will then be returning me > `['expression1']` as the result. > > > Why are there 2 different results? > > > I have tried using some mel-based commands such as `refreshAE` or `updateAE > <node path>`, in hope that the (whole) code block will be able to capture the > expression in the first run, but it is not. > > > Any ideas?
It's likely that since this creates the expression on an attribute change that only in the next "idle" state or upon a certain event post-process the expression gets added by Maya. Unfortunately I've found no way to actually make this process correctly. Here's some things I quickly tried: (Somehow I'm not getting the WYSIWYG editor, so I'm not sure code formatting will work) [CODE] import maya.mel from PySide2 import QtWidgets import time # Part01 img = cmds.imagePlane() frame_ext_attr = "{0}.useFrameExtension".format(img[0]) cmds.setAttr(frame_ext_attr, True) # Force update? (tests) for x in range(2): # Run twice so "any order" of commands after each other # is run and tested. QtWidgets.QApplication.instance().processEvents() cmds.refresh(force=True) maya.utils.processIdleEvents() maya.mel.eval("refreshAE;") maya.mel.eval("updateMainWindowComponentState();") time.sleep(0.05) # Part02 print '>>> ', cmds.listConnections("{0}.frameExtension".format(img[1])) [/CODE] -- 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/e82cf66e-391b-4c2f-be8e-d3829db5e116%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.