First question:

MStatus MFnGenericAttribute::addAccept( const MTypeId & id )

MFnGenericAttribute.addAccept() takes a MTypeId() object and you were
passing it om.MFnData.kMesh which is a enum or int.

Second question:

Read each prototype of the function or even click on the function
itself to jump to the description. Two of the
addAccept's state "Obsolete & no script support." and the other one I
answered above.


MStatus         addDataAccept (MFnData::Type newType)
MStatus         addAccept (MFnData::Type newType)
                Obsolete & no script support.
MStatus         addAccept (MFnNumericData::Type newType)
                Obsolete & no script support.

Third question:

The part you posted does not look like where the error is happening.
Turn on stack trace in your script editor
for better error reports if you dont have it on. It will give you line
numbers. I looked up the qwrap plugin
there are two spots with MVector. I am taking a shot in the dark here
as to your issue since I dont see the code.

import maya.OpenMaya as OpenMaya

//226
targetMesh = MObject(targetsArrayHandle.inputValue().asMesh())

//228
targetFnMesh = MFnMesh(targetMesh)

//229
intersections = OpenMaya.MPointArray()

//line 234
kMFnMeshPointTolerance = 1.0    #this is not in the file, I asume he had
a header and did not include it
targetFnMesh.intersect(sources[j], directions[j], intersections,
kMFnMeshPointTolerance, OpenMaya.MSpace.kWorld)

//line 239
del = OpenMaya.MVector(sources[j]) - OpenMaya.MVector(intersections
[0])


//line 291
del = OpenMaya.MVector(sources[i]) - OpenMaya.MVector(outPoints[i])


Hope that helps.


On Feb 10, 10:58 pm, jasonosipa <[email protected]> wrote:
> Okay, takeaway one is to go to those online docs, they are clearly
> more updated.  Smacks head.
>
> I'm still curious, though, since there are 3 things on that page that
> all say addAccept, and:
>
> MStatus MFnGenericAttribute::addAccept( const MTypeId & id )
>
> Doesn't say it's all dead/dying like the other two.  How does one know
> how to use it, or to steer clear of these three options:
>
> MStatus MFnGenericAttribute::addAccept( const MTypeId & id )
> # fine?
> MStatus MFnGenericAttribute::addAccept( MFnData::Type newType )
> # bad
> MStatus MFnGenericAttribute::addAccept( MFnNumericData::Type newType )
> # bad
>
> And even after going to dig through the online docs, I still can't
> figure out why this is dying:
>
> def compute( self, plug, data ):
>
>   if ( plug != qWrapNode.aOutShape ):
>     return om.kUnknownParameter
>
>   sourceFnMesh = om.MFnMesh ( data.inputValue
> ( qWrapNode.aSourceShape ).asMesh() )
>
>   sources    = om.MPointArray()       # where to shoot rays from
>   outPoints  = om.MPointArray()       # where they hit
>   directions = om.MFloatVectorArray() # direction to shoot rays
>
>   sourceFnMesh.getPoints(  sources,    om.MSpace.kWorld )
>   sourceFnMesh.getPoints(  outPoints,  om.MSpace.kWorld )
>   sourceFnMesh.getNormals( directions, om.MSpace.kWorld )
>
>   # create distances table - assign negative distance
>   distances = om.MDoubleArray()
>   distances.setLength( directions.length() )
>
>   for i in range( 0, directions.length() ):
>     distances[ i ] = -1
>
>   targetsArrayHandle = data.inputArrayValue( qWrapNode.aTargetShapes )
>
>   targetsArrayHandle.jumpToElement(0)
>
>   for i in range( 0, targetsArrayHandle.elementCount() ):
>
>     targetMesh    = targetsArrayHandle.inputValue().asMesh()
>     targetFnMesh  = om.MFnMesh( targetMesh )
>     intersections = om.MPointArray()
>
>     for j in range( 0, directions.length() ):
>
>       targetFnMesh.intersect( sources[ j ],
>                               directions[ j ],
>                               intersections,
>                               1.0e-10,
>                               om.MSpace.kWorld,
>                               None )
>
> <rest cut for brevity>
>
> It doesn't like "directions" for some reason, and gives me this:
>
> # TypeError: in method 'MFnMesh_intersect', argument 3 of type
> 'MVector const &' //
>
> Any ideas?  And again, thanks to all who help.  I would've given up on
> this long ago without this group as a resource.
--~--~---------~--~----~------------~-------~--~----~
Yours,
Maya-Python Club Team.
-~----------~----~----~----~------~----~------~--~---

Reply via email to