Community
Maya Programming
Welcome to Autodesk’s Maya Forums. Share your knowledge, ask questions, and explore popular Maya SDK topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Did Maya 2022 nodes template change? (python)

2 REPLIES 2
Reply
Message 1 of 3
formjune
700 Views, 2 Replies

Did Maya 2022 nodes template change? (python)

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
2 REPLIES 2
Message 2 of 3
formjune
in reply to: formjune

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
Message 3 of 3
formjune
in reply to: formjune

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report