Do you need to rename use_NewAPI -> maya_useNewAPI ? https://help.autodesk.com/view/MAYAUL/2022/ENU/?guid=Maya_SDK_A_First_Plugin_Python_HelloWorldAPI2_html
Also for future code, it would be better to use a pastebin or gist to retain the formatting, so that when your error contains line references, they can actually be located by others. Justin On Sun, May 21, 2023 at 12:01 PM Abdelhalim abulmagd < abdelhalim.abulm...@gmail.com> wrote: > i got this error when i run my first api code .. can anyone help me please > ! > > -------------------------- > the error : > > Error: TypeError: file > C:/Users/abdelhalim.abdo/Documents/maya/2024/plug-ins/api_learning.py line > 26: argument 1 must be OpenMaya.MObject, not MObject # > > ----------------- > > the code : > > > import maya.api.OpenMaya as om > > import maya.cmds as cmds > > > > def use_NewAPI(): > > pass > > > class MyCmd(om.MPxCommand): > > NAME = 'heycmd' > > def __init__(self): > > super(MyCmd, self).__init__() > > def doIt(self, args): > > print('this my first cmd :)') > > @classmethod > > def c(cls): > > return MyCmd() > > > def initializePlugin(p): > > vendor = 'abdo' > > version = '1.0.0' > > mfn = om.MFnPlugin(p, vendor, version) > > mfn.registerCommand(MyCmd.NAME, MyCmd.c) > > def uninitializePlugin(p): > > mfn = om.MFnPlugin(p) > > mfn.deregisterCommand(MyCmd.NAME) > > > > if __name__ == "__main__": > > p_name = 'api_learning.py' > cmds.evalDeferred(f'if cmds.pluginInfo("{p_name}", q=1, loaded=1): > cmds.unloadPlugin("{p_name}")') > cmds.evalDeferred(f'if not cmds.pluginInfo("{p_name}", q=1, loaded=1): > cmds.loadPlugin("{p_name}")') > > > -- > 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_maya+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/python_inside_maya/ee6a4d53-823c-4c06-a9a0-c7d53f4219c4n%40googlegroups.com > <https://groups.google.com/d/msgid/python_inside_maya/ee6a4d53-823c-4c06-a9a0-c7d53f4219c4n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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_maya+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA2jrjWmLomwqM0ALTBShF%2B6ettbZgUNstYs9wLuLFvU0w%40mail.gmail.com.