Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

'Create' command in python 2.0 API?

'Create' command in python 2.0 API?

Anonymous
Not applicable
448 Views
1 Reply
Message 1 of 2

'Create' command in python 2.0 API?

Anonymous
Not applicable
Hi,

I am trying to create a plugin command in the new Python 2.0 API. The problem is that I cannot find the method asMPxPtr(). Is that method needed and in that case, where is it?

I am asking since I get this error when not using it:

Error: RuntimeError: file <string> line 2: Failed to convert result of script creator function


this is when returning an instance of my MPxCommand derived class (as described in the docs):

createCmdFunc is a Python callable which takes no arguments and returns a new instance of the MPxCommand-derived class.


Anyone has any insight into this?
0 Likes
449 Views
1 Reply
Reply (1)
Message 2 of 2

drew_avis
Autodesk
Autodesk

Hi, you don't need to use asMPxPtr() with the 2.0 API.  You can do this in your creator function:

 

 

1.0:

# Creator
def cmdCreator():
    return OpenMayaMPx.asMPxPtr( scriptedCommand() ) 

 

 

2.0:

# Creator
def cmdCreator():
    return  scriptedCommand() 

 

def maya_useNewAPI():

    pass

 

 

 

Hope that helps.



Drew Avis
Content Experience Designer