Maya Plug

95 views
Skip to first unread message

Rémi Deletrain

unread,
Jan 11, 2016, 11:23:52 AM1/11/16
to Python Programming for Autodesk Maya
Hello everyone.

I have a problem with Mplug.

I try to create inputs in MFnNumericsAttribute array in connectionMade function of my MPxNode.

--------------------------------------------------------------------------------------------------

#   Function when connection made in node
def connectionMade(self, plug, otherPlug, asSrc):

    if not asSrc and plug == self.aSourceGeometry:
        self.add_weights_attributes(plug)

    return OpenMayaMPx.MPxNode.connectionMade(self, plug, otherPlug, asSrc)

#   Add weights attributes from source geometry cvs
def add_weights_attributes(self, plug):

    #   Plug Datas
    sourceGeometryHandle = OpenMaya.MPlug(self.thisMObject(), self.aSourceGeometry)
    sourceGeometryObject = sourceGeometryHandle.asMObject()

    weightsHandle = OpenMaya.MPlug(self.thisMObject(), self.aInputWeights)

    #   Curve
    mfnCurve = OpenMaya.MFnNurbsCurve(sourceGeometryObject)
    numCVs = mfnCurve.numCVs()

    #   Set Num of weights element
    weightsHandle.setNumElements(numCVs)

--------------------------------------------------------------------------------------------------

I wish that when I connect a geometry in my node It adds as many inputs in my MFnNumericAttribut there points.

I thought it was this command "setNumElements" but nothing happens ...

Someone an idea? 

Daniel Lindsey

unread,
Jan 28, 2016, 8:06:14 PM1/28/16
to Python Programming for Autodesk Maya
You need to set the attribute to an array type, and if you want to build it, you need to use the setUsesArrayBuilder as well.

Rémi Deletrain

unread,
Feb 22, 2016, 6:44:14 AM2/22/16
to Python Programming for Autodesk Maya
THX Daniel.

Indeed I try with arrayBuilder and it works
Reply all
Reply to author
Forward
0 new messages