Actually, it seems I have have spoken too hastily.  I've still having
problems with making a python MPxParticleAttributeMapperNode - even if I
specify the mpx type when calling registerNode:

import maya.OpenMaya as om
import maya.OpenMayaMPx as mpx

class ParticleAttributeMapperNode(mpx.MPxParticleAttributeMapperNode):
    id = om.MTypeId(0x870350)

    def isAbstractClass(self):
        return False

def initialize():
    pass

def creator():
    return mpx.asMPxPtr( ParticleAttributeMapperNode() )


def initializePlugin(mobject):
    mplugin = mpx.MFnPlugin(mobject)
    mplugin.registerNode( 'dummyParticleAttr',
                          ParticleAttributeMapperNode.id,
                          creator,
                          initialize,
                          mpx.MPxNode.kParticleAttributeMapperNode,
                           )

def uninitializePlugin(mobject):
    mplugin = mpx.MFnPlugin(mobject)
    mplugin.deregisterNode( ParticleAttributeMapperNode.id )


Then when I try to create a node, I get:


>>> import maya.cmds as cmds
>>> cmds.createNode('dummyParticleAttr')
# Warning: Node type 'TdependNode' is abstract. Cannot create. #
# Error: Failed to convert script pointer to c pointer: MPxNode * (converter
failed on type)
# # TypeError: Failed to convert script pointer to c pointer: MPxNode *
(converter failed on type)
# There is no such dependency node type: dummyParticleAttr.


I'm really stuck here.  Any ideas? Is this just a maya bug?  Things seem to
work fine when using a compiled MPxParticleAttributeMapperNode...

- Paul

On Fri, Jan 28, 2011 at 3:44 PM, Judah Baron <[email protected]> wrote:

> We've all done it:)
>
> On Fri, Jan 28, 2011 at 2:05 PM, Paul Molodowitch <[email protected]>wrote:
>
>> Never mind, I'm being dumb - just forgetting the 5th arg to registerNode,
>> which specifies the type MPx type. >(
>>
>> Move along, move along...
>>
>> - Paul
>>
>>
>> On Thu, Jan 27, 2011 at 6:30 PM, Paul Molodowitch <[email protected]>wrote:
>>
>>> I was wondering if anyone else has been able to make
>>> an MPxParticleAttributeMapperNode in a python plugin... or perhaps have
>>> someone else verify that it isn't working.
>>>
>>> I boiled down the script to the bare minimum:
>>>
>>> import maya.OpenMaya as om
>>> import maya.OpenMayaMPx as mpx
>>>
>>> class ParticleAttributeMapperNode(mpx.MPxParticleAttributeMapperNode):
>>>     id = om.MTypeId(0x870350)
>>>
>>> def initialize():
>>>     pass
>>>
>>> def creator():
>>>     return mpx.asMPxPtr( ParticleAttributeMapperNode() )
>>>
>>>
>>> def initializePlugin(mobject):
>>>     mplugin = mpx.MFnPlugin(mobject)
>>>     mplugin.registerNode( 'dummyParticleAttr',
>>>                           ParticleAttributeMapperNode.id,
>>>                           creator,
>>>                           initialize )
>>>
>>> def uninitializePlugin(mobject):
>>>     mplugin = mpx.MFnPlugin(mobject)
>>>     mplugin.deregisterNode( ParticleAttributeMapperNode.id )
>>>
>>>
>>>
>>> ... and it still isn't working.  It will import fine, but if you try to
>>> actually create an instance of such a node, it fails:
>>>
>>> if not cmds.pluginInfo(plugin, loaded=1, q=1):
>>>
>>> cmds.loadPlugin(plugin)
>>>
>>> cmds.createNode('dummyParticleAttr')
>>>
>>>
>>> Note that this script will work with pretty much ANY other MPxNode type -
>>> just swap out the MPxParticleAttributeMapperNode for, say, an
>>> MPxSurfaceShape, or MPxDeformerNode, and it can create one.
>>> Anyone else have any success with this, or at least want to confirm if it
>>> is / isn't working for them?
>>>
>>> Thanks,
>>>
>>> - Paul
>>>
>>
>>  --
>> http://groups.google.com/group/python_inside_maya
>>
>
>  --
> http://groups.google.com/group/python_inside_maya
>

-- 
http://groups.google.com/group/python_inside_maya

Reply via email to