PDA

View Full Version : Iterate over nurbsSurface CVs


Jugdish
11-03-2005, 01: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 nurbsSurface1.cv[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-03-2005, 11:08 AM
http://www.robthebloke.org/mel/DATA_nsurf.html

Robert Bateman
11-03-2005, 11:11 AM
you can also do :

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

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

AndersEgleus
11-03-2005, 11:52 AM
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.

Jugdish
11-03-2005, 12:44 PM
Great suggestions, thanks guys!

CGTalk Moderation
11-03-2005, 12: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.