Lets say I want 10 equally spaced out points on the curve, this is how I 
usually do it:

int m_numDup = 10;

MFnNurbsCurve fnCurve(oCurve);
double length = fnCurve.length();
MPoint p;
for (int i=0; i <= m_numDup; i++){
MPoint p;
double param = fnCurve.findParamFromLength(i* ( (1.0 / 
float(m_numDup))*length) );
fnCurve.getPointAtParam(param, p, MSpace::kWorld );
}

On Monday, April 20, 2015 at 10:33:30 AM UTC+2, Emre Tekinalp wrote:
>
> Hello everybody,
>
> I know this is mostly a Python forum, but I'm currently writing in C++ a 
> deformer,
> dealing with curves yaay, hopefully it is ok nonetheless, otherwise I come 
> up with a python api example...
> I have also looked through the forum and could find just a 
> MFnMesh.closestPoint issue, which does not really help me unfortunately.
>
> My maya setup is as follows:
> - I have an ep curve degree=3
> - I want to affect a polyCylinder with the curve, like the wireTool
> - As a current idea, one of the steps to achieve that is to get the 
> closestPoint and param on the curve for each Vertex on my polyCylinder.
> - For that I use MFnNurbsCurve closestPoint, but when I'm cout position 
> and param values, 
>   they are mostly zeroed out and when I'm in component mode selecting the 
> vertices of the mesh and move them down in ty
>   I get a bunch of value changes, but only when I'm less then 0, 
> everything above stays 0 (position and param values)
> - Here is the code:
>
>
> // Inside the deform method
>
>     //Get the closestPoint and param on the curve from each vertex
>     MFnNurbsCurve fnCurve(oCurve); //Assume we have the MObject of the 
> curve already
>     double param;
>     MPoint position;
>
>     for (;! iter.isDone(); iter.next())
>     {
>         //Helper method to retrieve/store the position and param value on 
> the curve
>         getClosestPoint(fnCurve, iter.position(), position, param);
>         cout << "index: " << iter.index() << " point: " << position.x << " 
> " << position.y << " " << position.z << " param: " << param << endl;
>     }
>
> void Curve::getClosestPoint(MFnNurbsCurve& fnCurve, MPoint inPosition, 
> MPoint& position, double& param)
> {
>     position = fnCurve.closestPoint(inPosition, &param, 0.0, MSpace::
> kWorld);
> }
>
>
>
>
> This is basically a part from the closestPoint/TangentAndDistance.cpp 
> source file.
> But for any kind of reason, I don't get proper values... am I missing 
> something?
>
> Thanks in advance!
> Emre
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/dff38dd7-5488-4ef5-8b70-a67bf05a2c25%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to