ECToo / pymel

Automatically exported from code.google.com/p/pymel
0 stars 0 forks source link

Hard to get maya/plugin/script load order correct to register a virtual class in batch. #259

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
When using pm.factories.registerVirtualClass() to register a custom node class 
it can be hard to get the load order correct. I think this is mainly a problem 
in batch where evalDeferred() isn't necessarily deferred. This is the execution 
order that is causing me trouble:

* Maya Loads
* PyMel Loads
* Maya Loads the scene, triggers custom plugin load.
* Plugin loads, calling cmds.evalDeferred("code that calls 
registerVirtualClass()") to tell PyMel about the custom class.
* registerVirtualClass() runs, but the plugin (I think) isn't finished loading 
because evalDeferred() isn't deferred in batch.
* Exceptions are thrown, Maya burns and dies. Looks like this:

# # Traceback (most recent call last):
# #   File "<maya console>", line 1, in <module>
# #   File custom_pymelClass.py", line 59, in <module>
# #     class MyNewClass(pm.nt.MyNode):
# # AttributeError: '_LazyLoadModule' object has no attribute 'MyNode'

This is using PyMel 1.0.3, Maya 2011 and Linux 2.6.30.10-105.2.23.fc11.x86_64 
SMP

I've also managed to recreate this bug when loading a scene that requires the 
plugin from the command line with Maya,e.g.:

  maya-2011 /path/to/a/scene.mb

Cheers, James.

Original issue reported on code.google.com by james.st...@gmail.com on 20 Sep 2011 at 12:27

GoogleCodeExporter commented 9 years ago
I'm a little confused.. i'm guessing MyNode is a (regular) node created by the 
plugin... and MyNewClass is a virtual class based off of it.  But then, if 
you're already creating new node types, why are you bothering with virtual 
classes?

could you give us a more concrete example? ideally, a complete plugin file that 
exhibits the problem.  

Original comment by elron...@gmail.com on 12 Oct 2011 at 8:24

GoogleCodeExporter commented 9 years ago
Hi,
 MyNewClass is a pymel extension, it's not sub-classed from MyNode.

MyNewClass adds python properties and methods. So I can do this kinda of thing:

node.customMethod()

J.

Original comment by james.st...@gmail.com on 20 Oct 2011 at 4:35

GoogleCodeExporter commented 9 years ago
Hi, any reason this is still on hold?

Original comment by james.st...@gmail.com on 21 Feb 2012 at 7:14