Waiting for Maya to complete an action

574 views
Skip to first unread message

Mark Dietel

unread,
Oct 1, 2013, 12:59:12 PM10/1/13
to python_in...@googlegroups.com
Hey guys,

This post isn't python specific, so forgive me if it's misplaced.

I'm having some trouble interacting with an imagePlane after enabling the "useFrameExtension" attribute. Once this attribute is enabled, there should be an expression connected to the imagePlane node. I want to delete that expression in order to create my own key frames. The problem is that when I script these actions the expression doesn't get created until Maya regains control from the script.

For example, if I run this script;

imagePlaneName = "imagePlane1" # assuming this has already been created
cmds.setAttr( "%s.useFrameExtension" % imagePlaneName, 1 )
connected_expressions = cmds.listConnections("%s.frameExtension" % imagePlaneName, source=True, destination=False)

connected_expressions will be empty.

I've tried sleeping the script and looping over the listConnections like this

cmds.setAttr( "%s.useFrameExtension" % imagePlaneName, 1 )

while not connected_expressions:
connected_expressions = cmds.listConnections("%s.frameExtension" % imagePlaneName, source=True, destination=False)
time.sleep(1)


...but neither seems to allow Maya to create the expression. The only thing that seems to work is to stop the script entirely and give control back to Maya. Like this;

cmds.setAttr( "%s.useFrameExtension" % imagePlaneName, 1 )
STOP THE SCRIPT
connected_expressions = cmds.listConnections("%s.frameExtension" % imagePlaneName, source=True, destination=False)

In this final case, the connected_expressions variable will contain a list of at least one expression. The one I need.

How can I delay my script or force Maya to continue the expression creation so that I can act on the expression?

Jesse Kretschmer

unread,
Oct 1, 2013, 1:28:50 PM10/1/13
to python_in...@googlegroups.com
I'm not sure what you are aiming to do after you get connected_expressions set. It is likely that the node attribute change has not yet been computed by maya.

I'd have to kick the tires a bit, but I imagine you could change the way you are wiring things up to get the data you need. 

Another option might be running cmds.evalDeferred(). This would probably cause some confusion in the way that your code is written. It would also mean that the code may not execute when you expect.



--
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 post to this group, send email to python_in...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/f9676b7a-74b4-4522-8cf6-b9ee2cfe553b%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Mark Dietel

unread,
Oct 1, 2013, 9:20:02 PM10/1/13
to python_in...@googlegroups.com
It turns out my approach was flawed.  I wanted to get the expression so that I could remove it and replace it.  However, since it doesn't exist until the termination of the script, I have just attached my own expression during script run time.  Maya never has a chance to connect it's own.

Problem solved.  (I suppose, there never really was a problem.  Problem...uninvented?)

860323

unread,
Oct 2, 2013, 5:54:02 AM10/2/13
to python_in...@googlegroups.com, python_in...@googlegroups.com
Hi, guys:
I just guess some problem because I in the load of back home. When we executed the script:

imagePlaneName = "imagePlane1"

The plane not attribute useFrameExtension until the maya executed other Mel script, it is maya internal. So you can't get the listConneuseFrame info until you stop the scrip or maya finished the Mel script!

If it be the case, you can use the script to create the attribute, or use getAttr to judge the attribute is exists.

I sorry the puzzle from my guess wrong!

Sent from my iPhone

On 2013年10月2日, at 9:20, Mark Dietel <mdi...@gmail.com> wrote:

It turns out my approach was flawed.  I wanted to get the expression so that I could remove it and replace it.  However, since it doesn't exist until the termination of the script, I have just attached my own expression during script run time.  Maya never has a chance to connect it's own.

Problem solved.  (I suppose, there never really was a problem.  Problem...uninvented?)

On Tuesday, October 1, 2013 9:59:12 AM UTC-7, Mark Dietel wrote:
Hey guys,

This post isn't python specific, so forgive me if it's misplaced.  

I'm having some trouble interacting with an imagePlane after enabling the "useFrameExtension" attribute. Once this attribute is enabled, there should be an expression connected to the imagePlane node.  I want to delete that expression in order to create my own key frames.  The problem is that when I script these actions the expression doesn't get created until Maya regains control from the script.

For example, if I run this script;

imagePlaneName = "imagePlane1"  # assuming this has already been created
cmds.setAttr( "%s.useFrameExtension" % imagePlaneName, 1 )
connected_expressions = cmds.listConnections("%s.frameExtension" % imagePlaneName, source=True, destination=False)
 
connected_expressions will be empty.

I've tried sleeping the script and looping over the listConnections like this

cmds.setAttr( "%s.useFrameExtension" % imagePlaneName, 1 )

while not connected_expressions:
    connected_expressions = cmds.listConneuseFrameExtensionctions("%s.frameExtension" % imagePlaneName, source=True, destination=False)

    time.sleep(1)


...but neither seems to allow Maya to create the expression.  The only thing that seems to work is to stop the script entirely and give control back to Maya.  Like this;

cmds.setAttr( "%s.useFrameExtension" % imagePlaneName, 1 )
STOP THE SCRIPT
connected_expressions = cmds.listConnections("%s.frameExtension" % imagePlaneName, source=True, destination=False)

In this final case, the connected_expressions variable will contain a list of at least one expression.  The one I need.

How can I delay my script or force Maya to continue the expression creation so that I can act on the expression?

--
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 post to this group, send email to python_in...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages