Problem with curve CV position

hello all, i have a little problem with a mel script, i need to get the position XYZ of all CVs in a curve, now i already now how many CV do i have in the curve using the method in the manual (spans + degree) it works well now, i need to get each XYZ pos per cv into an array, now cv[n] is already and array and i cant have multidimensional arrays, so i try to use matrix but i dont know how big the matrix need to be and i try this but i get an error

matrix $CVsPos[`CVCount($curve)`][3];
matrix $CVsPos[$totalCV][3];

and i got errors with both, so if i dont know how big the matrix need to be, and i cant use a matrix without initializatiing it what can i do

how about just using the pointPosition command and building a new array..?

:nathaN

i already work it out, all i need was some sleep, this is what i did

proc vector[] LMgetCVsPos (string $selection[])
{
// string $selection[] = ls -sl;
string $curve = $selection[0];
int $totalCV = LMCVCount($curve);
vector $CVsPos[];
int $i;

for ($i = 0; $i <= $totalCV; $i++)
{
$CVsPos[$i] = `getAttr $curve.cv[$i]`;
}

return $CVsPos;
}

i found myself again into another problem, i need to have a button, that when click it let you draw CV curves, that pretty straigh fordwar in using this
$curCtx =
curveCVCtx -d 1`;
setToolTo $curCtx;

then starts my problem i need that when the curve is finish, i have to add a custom attribute

string $Selection[] = ls -sl;
string $curve = $Selection[0];
addAttr -ln AI_Path -dt "string" -k false $curve;
setAttr -type "string" $curve.AI_Path "AIPath";

i using that becouese when you finish the curve is automatic selected. the problem is that maya dosent wait for me to complete the current tool and it goes to the next line of the script witch dosent work becouse there is nothing selected. anyone can help me with this

maya isnt brilliant at giving you methods of breaking code up into blocks where user interaction can occur...which may well be quite fair enough!

a couple of the more straight forward ways: one is to use scriptJobs, and detect the creation of the new node (and label it with your attribs) and another to detect completion of the tool ctx (which then kicks off into the next part of your script, as an additional, discrete, global proc entry point). you can also just make assumptions about what the curve will be named and do your business with just the tool completion event. another method might be to throw up a little window with buttons that the user can push after they've completed their creative efforts, or decided they want to bail (with the right course of script action attached to those buttons).

cheers

yep iwas trying that with script jobs but still dosent work
i have something like this, more or less

proc LMcreatePathAI()
{
$curCtx = curveCVCtx -d 1;
setToolTo $curCtx;
int $jobNum = scriptJob -e "DagObjectCreated" "LMmakeAI";
scriptJob -kill $jobNum -force;
}

proc LMmakeAI()
{
string $Selection[] = ls -sl;
string $curve = $Selection[0];
addAttr -ln AI_Path -dt "string" -k false $curve;
setAttr -type "string" $curve.AI_Path "AIPath";
}

and i always get this error

// Warning: line 14: Cannot add attributes to components. 'curveShape1.controlPoints[0]' ignored. //
// Error: line 14: Found no valid items to add the attribute to. //

how can i detect the completion of a tool, i been looking for something like that, but no luck

with a couple of mods this should do it...

im not sure how you managaed to have it working before with the new scriptJob being killed striaght after its creation (maybe that was a different script version?)...but in anycase, the error you were getting was becuase you were working on the selection, which is initially a single CV when the curve node is created, and the error message explains the rest. you could have querried the parent of the component to get the shape with that setup.

can i ask what the tool is that you are building?

cheers.

sure you can ask, i`n building a tool where the artist can create a path, that the game agent (NPC character) can fallow, and have some properties in the desire point (CV) to change the action (the animation thats played) and them export that to a text file, so that the game engine can read it, nothing too complex, is just that i never done something like this before.

thanks a lot for the help Campbell