LumaPictures / pymel

Python in Maya Done Right
Other
479 stars 130 forks source link

Virtual Classes bugged in 1.0.5 #340

Closed pmolodo closed 8 years ago

pmolodo commented 8 years ago

From kyle.mis...@gmail.com on September 19, 2013 17:45:35

I can't register any virtual classes - they are rejected because 'apicls' is an attribute present on the new class, which is not a part of the virtual class manager's validSpecialAttrs list. I suspect this has to do with a change to the metaclasses for PyNodes adding more attributes to all classes. What Version of Maya are you using? Maya 2014 On what operating system? (be as specific as possible and include service packs, 64bit vs 32bit, etc) Win7 64bit What Version of PyMEL are you using? 1.0.5 What is the expected output? What do you see instead? I expect to not find apicls in the dict of classes inheriting from a PyNode. If possible, provide a few lines of code to reproduce the problem. It helps us if your code will reproduce the problem from a new scene. Here's an example that demonstrates the presence of more attributes in 2014: from pymel.core import * class NewNet( nt.Network ): pass NewNet.dict.keys()

The result in Maya 2011:

Result: ['slots', 'doc', 'module', 'readonly', 'melnode']

The result in Maya 2014:

Result: ['module', 'MAttrClass', 'MdgTimerState', 'apicls', 'melnode', 'doc', 'slots', 'MdgTimerMetric', 'readonly', 'MdgTimerType'] # Does maya.cmds exhibit the same problem? n/a Please provide any additional information below. Not even the examples from the custom class examples ( https://github.com/LumaPictures/pymel/blob/master/examples/customClasses.py ) work on Maya 2014

Original issue: http://code.google.com/p/pymel/issues/detail?id=307

pmolodo commented 8 years ago

From dean.edm...@gmail.com on January 23, 2014 05:33:13

This looks to be a duplicate of issue #295 , which contains a fix for the problem.

pmolodo commented 8 years ago

From kyle.mis...@gmail.com on January 24, 2014 13:35:31

While you can simply add apicls to the list of accepted attributes, it seemed like a sort of hacky fix to me, since apicls was not present in the exceptions in earlier versions of pymel, yet it still worked fine. I did some digging and found a difference in pymel.internal.factories.MetaMayaNodeWrapper.new where the apicls attribute is actually added to the nodes:

2014

if apicls is not None: classdict['apicls'] = apicls

2011

if apicls is not None: if apicls in MetaMayaNodeWrapper.completedClasses: pass
else: MetaMayaNodeWrapper.completedClasses[ apicls ] = classname classdict['apicls'] = apicls

Essentially, in 2011, the apicls attr was only added to a node if it had not already been added to a parent node. This basically meant that abstract node types had the apicls attribute, while the concrete subclasses would not, and would work as Virtual Classes. I think this change is actually the source of the issue.

pmolodo commented 8 years ago

From elron...@gmail.com on January 24, 2014 14:37:23

fixed with: https://github.com/LumaPictures/pymel/commit/a257f00b37ef9796bbca154d4bc7293ac45b18dc

Status: Fixed