Mailing List
Home
Forum Home
Softimage
Carrara
trueSpace
Dir3d-l
Maya - a powerful 3D animation and visual effects software
Macromedia Flash Development
Subjects
Cameras
scaleDown command
black out solved
Aircraft Tutorial
Mathematical XYZ ?
Its done This vs That
Its done first week
recommendations for screen video captures?
3DExplorer "Oddity "
New Director
ProTeam renewals
Fuel 's new websites (X post)
Blue peter create a make toy
targeting groups question
XPost: Shockwave 3D game ( sort of )
RES: RES: RES: Fish Modeling
Emitting particles from object intersection
Fuel 's new websites (X post)
Texturing
Big Break Contest Videos
New Plugins
Models and Texture on my updated site
Error Installing Patch tS6 6
Plasma?
Looking for Inspiration
Weird EMail Q
It 's done first week ?
Cherry not cranberry
New game
Camera Animation Problem
Particle plugins?
 
Newbie - mel - Getting points, vrtx or controlpoints

Newbie - mel - Getting points, vrtx or controlpoints

2003-12-02       - By Bryan Ewert

 Back
Reply:     1     2     3     4     5     6     7  

? from Tue, 2 Dec 2003 10:33:03 -0600

> > So I either need to find a way to automatically select all the CV's or
> > somehow get a list of them.

> hilite -r $obj;
> eval ("hilite -r " + $obj + ".vtx[0:2000000]");

Oi. Sorry, but that's just too sloppy for me. :)

The CVs on a NURBS curve are selectable via the ".cv" attribute of the
curve. Edit points are selectable via the ".ep" attribute.

To determine the number of CVs for a NURBS curve:

 string $curve = "curveShape1";

 int $numSpans = `getAttr ( $curve + ".spans" )`;
 int $degree   = `getAttr ( $curve + ".degree" )`;
 int $form     = `getAttr ( $curve + ".form" )`;

 int $numCVs   = $numSpans + $degree;

 // Adjust for periodic curve:
 if ( $form == 2 ) $numCVs -= $degree;

Thus, to select or modify all CVs on the curve:

 int $cv;
 for ( $cv = 0; $cv < $numCVs; $cv++ )
 {
   // The CV; e.g. "curveShape1.cv[0]"
   string $cvAttr = ( $curve + ".cv[" + $cv + "]" );

   // The edit point; e.g. "curveShape1.ep[0]"
   string $cvAttr = ( $curve + ".ep[" + $cv + "]" );

   select $cvAttr;  // or whatever
 }

Related MEL How-To's:

 How do I determine how many CVs are in a NURBS Curve or
 Surface?

   http://www.ewertb.com/maya/mel/mel_a58.html

 How can I determine the world space coordinates of NURBS
 surface edit points?

   http://www.ewertb.com/maya/mel/mel_a20.html

If you're dealing with polygon mesh objects, you can use the "polyEvaluate"
command to determine the number of vertices in the mesh:

 string $mesh = "pSphereShape1";

 polyEvaluate -vertex $mesh;
 // Result: 114 //

An annoying behavior of this command is that it always returns an int array,
forcing you to capture its results like this:

 int $numVtx[] = `polyEvaluate -vertex $mesh`;

 int $vtx;
 for ( $vtx = 0; $vtx < $numVtx[0]; $vtx++ )
 {
   string $vtxAttr = ( $mesh + ".vtx[" + $vtx + "]" );
   
   // Do work the $vtxAttr here.
 }

You can then loop through the vertices similar to the CVs.


Sidebar: You won't find the ".cv" or ".ep" attributes listed in the
Connection Editor, or in the node documentation for a nurbsCurve. These are
"virtual" attributes - perhaps aliases, I'm not sure how they defined and
interpreted - similar to the ".vtx" and ".e" attributes on a polygon mesh.
Does someone knows the story behind these?

--
Bryan Ewert  ? maya@(protected) ? http://www.ewertb.com ?

-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---
List-help: <mailto:listar@(protected)?Subject=help>
List-unsubscribe: <http://www.highend3d.com/maya/listserver/>
List-subscribe: <http://www.highend3d.com/maya/listserver/>
List-archive: <http://www.highend3d.com/maya/archive/>