View Full Version : Iterate over nurbsSurface CVs

11 November 2005, 02:08 AM
I've found any easy way to get the total number of vertices on a poly surface, by doing a `getAttr -size polygon1.vt`, but how can you get the total number of CVs on a nurbsSurface, such that you can iterate over them properly?

I've tried using the minMaxRangeU and minMaxRangeV attributes of nurbsSurface objects to get this information, but it doesn't seem to be accurate. For example, there is one nurbsSurface that when I select all of its CVs (by dragging across them), the Script Editor says:

select -r[0:15][0:11]

This tells me that there are 16 CVs in the U direction and 12 in the V direction (right?). However, when I call minMaxRangeU and minMaxRangeV on this same surface, I get the following:

getAttr nurbsSurface1.minMaxRangeU;
// Result: 0 11 //
getAttr nurbsSurface1.minMaxRangeV;
// Result: 0 8 //

which is not consistent with the actual number of CVs. So how do I get the total number of CVs for a nurbsSurface so I can iterate over them??

Robert Bateman
11 November 2005, 12:08 PM

Robert Bateman
11 November 2005, 12:11 PM
you can also do :

select -r["*"][0];
$num_cvs_In_u = size(`ls -fl -sl`);

select -r[0]["*"];
$num_cvs_In_v = size(`ls -fl -sl`);

11 November 2005, 12:52 PM
if you use .cp instead, it will give you the total number of cvs, and let you iterate over all of them (this won't allow you to iterate over u and v cvs separately though)

int $numCVs = `getAttr -size myNurbsSurface1.cp`;

for ($i = 0; $i < $numCVs; $i++)
float $pos = `xform -ws -t (myNurbsSurface1.cp + "[" + $i + "]")`;

The .cp attribute works with both polygons, nurbs and lattices.

11 November 2005, 01:44 PM
Great suggestions, thanks guys!

CGTalk Moderation
11 November 2005, 01:44 PM
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.