PDA

View Full Version : surfacInfo


xcomb
10-31-2006, 06:45 AM
I am trying to store float array of cvs and later query them to constraint my locators to cv position.
I am getting an error, saying Error: Invalid redeclaration of variable "$m" as a different type.
well i don't understand, i've tryed pretty much everything, as strings, int float vector as arrays and not, but i can't cast into variable for some reason.

I want to be able to use the size of cvs stored in surface and looking up the surfaceInfo node to get them, i can get their position, which i want and the amount.

string $nurbs[] = `ls -sl`;
string $si = `createNode surfaceInfo`;
connectAttr -f ($nurbs[0]+".worldSpace") ($si+".inputSurface");
float $m[] = `getAttr surfaceInfo1.controlPoints["*"]`;
int $size = size($m);
for($i = 0; $i < $size; $i++){
string $loc[] = `spaceLocator`;
connectAttr -f ($si+".controlPoints[$i]") ($loc[$i]+".translate");
}

westiemad
10-31-2006, 10:07 AM
in the shell as soon as you type:

float $m;

and hit enter, you have declared the $m as a single float, that global to maya. When, like I do you think "Oh crap that was supposed to be an array" you CAN'T just go:

float $m[];

as it pukes about redeclaration, the solution is to restart maya, yes I know.

Secondly you need to concatinate the $i, so in the loop it should be:

connectAttr -f ($si + ".controlPoints[" + $i + "]") ($loc[$i]+".translate");

although this doesn't work. I'd try something like point position:

pointPosition -w chicken.cv[3];

xcomb
10-31-2006, 08:00 PM
Thanks it worked, but it lags so badly, not sure why.
I queried 231 ControlPoints, but i only specified 9 locator to constraint to cvs, and this seems to lag maya.

westiemad
11-01-2006, 09:46 AM
it depends what you want to constrain 231 locators onto a nurbs surface for, feathers? There are applications where expressions are better than constraints, you don't actually need to use a constaint if your wanting to position 2 objects together, you can use some of maya handy utility nodes.

xcomb
11-01-2006, 03:06 PM
No no i didn't mean constraints altogether, just as term to constraint an object to the surface.
Actually i am practicing in MEL, and i give mysefl tasks to solve :)
As for this task, i wanned simply to put objects onto surface verteces or cvs, so they can stay put. I know ather technics like using Hair folicles, but i wanned this way, is to query surface cvs and assign their world space coordinates onto my locator.

goleafsgo
11-01-2006, 03:32 PM
in the shell as soon as you type:

float $m;

and hit enter, you have declared the $m as a single float, that global to maya. When, like I do you think "Oh crap that was supposed to be an array" you CAN'T just go:

float $m[];

as it pukes about redeclaration, the solution is to restart maya, yes I know.

A common thing to do when typing stuff into the script editor is to wrap what you are executing with {}...then it doesn't get declared as global.

So:


{
float $m[] = `getAttr surfaceInfo1.controlPoints["*"]`;
}

in the script editor won't make $m global and you can change it if you have made a typo...just make sure that you have the {} selected as well when you execute it.

xcomb
11-01-2006, 04:18 PM
Yeah i forgot about the scope :)

Thanks for reminding me.

CGTalk Moderation
11-01-2006, 04:18 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.