Did Maya 2022 nodes template change? (python)

Did Maya 2022 nodes template change? (python)

formjune
Participant Participant
1,012 Views
2 Replies
Message 1 of 3

Did Maya 2022 nodes template change? (python)

formjune
Participant
Participant

Just tried to port one of my scripts to Maya 2022 and noticed that templates don't work. Maya imports my .py file but seems to ignore its content at all. Python 2 mode works fine

sss
0 Likes
1,013 Views
2 Replies
Replies (2)
Message 2 of 3

formjune
Participant
Participant

Update: 

It's a bug.

 

Here's a little code. Works perfectly in Python 2 mode.

In Python 3 I can register it, AELoader.loadedTemplates() confirms that template is loaded,  but when I create node and open attribute editor it throws exception:

# Error: line 2: ValueError: file C:\Program Files\Autodesk\Maya2022\Python37\lib\site-packages\shiboken2\files.dir\shibokensupport\__feature__.py line 142: level must be >= 0 #

 

 

import maya.api.OpenMaya as om2
import pymel.core as pm

maya_useNewAPI = True

class Template(pm.ui.AETemplate):
_nodeType = "testNode"

def __init__(self, *args):
self.beginScrollLayout()
self.addExtraControls()
self.endScrollLayout()

class Node(om2.MPxNode):
NAME = "testNode"
ID = om2.MTypeId(0x00047374)

@classmethod
def initialize(cls):
pass

def initializePlugin(m_object):
plugin = om2.MFnPlugin(m_object)
plugin.registerNode(Node.NAME, Node.ID, Node, Node.initialize)

def uninitializePlugin(m_object):
plugin = om2.MFnPlugin(m_object)
plugin.deregisterNode(Node.ID)

 

sss
0 Likes
Message 3 of 3

formjune
Participant
Participant

Found a solution:

open Maya2022\Python37\Lib\site-packages\pymel\core\uitypes.py

find AELoader.load() method and and remove -1 from __import__() arguments. It fixes a problem for cases when template is placed in another module and being imported.

Otherwise throws exception: AttributeError: module 'builtins' has no attribute 'ClassName'

sss