View Full Version : how to get number of CV for selected obj

11 November 2006, 01:22 PM
How to store the CV's for a selected nurbs object in a variable??

thanks :)

11 November 2006, 02:13 PM
Hey instruct9r,

// get the selected object to get the number of CVs from

$bj_selectedObject = `ls -sl`;

// to get the number of CVs, I store the vector of all CVs and
// divide it by 3 (the vector variable is a compound variable with
// 3 floating values)

$bj_vectors = eval("getAttr " + ".cv[\"*\"][\"*\"]");
$bj_CVs = size($bj_vectors)/3;

$bj_CVs is the variable with number of CVs stored.

Hope it helps...

11 November 2006, 02:56 PM
cool.. thanks..

i was thinking about something like the "polyEvaluate" that returns the number of the vertex for selected object..but this one is also appropriate..

1 more.. could you explain please why you use

$bj_vectors = eval("getAttr " + ".cv[\"*\"][\"*\"]");

instead of:

$bj_vectors = `getAttr ".cv[\*\][\*\]"`;

and i was thinking that Maya will get error if you dont define the variable "$bj_vectors" as an array.. but it doesn't..

thanks :)

11 November 2006, 06:23 PM
just another way to do that..

int $nCvs = size (`ls -fl ("

will give the number of cv's.. flattened......
got this from some other place.. but very handy...

12 December 2006, 08:56 AM
I got an error message when running this command:

;So I guessed I had to use quotation marks before and after asterisk...

Thanks for the tip, but you can even lose those escape characters.

$bj_vectors = `getAttr ".cv

Or you can write everything in one line
$bj_nCVs = size(`getAttr ".cv

"`)/3; I like underearth's code, but you will need another line if you want get number of CVs from selected nurbs object.

CGTalk Moderation
12 December 2006, 08:56 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.