View Full Version : 1-2 questions about poly functions expressions

 ph0t0n1st12 December 2007, 01:07 PMHi, I have some questions about getattr and vertex size. I wanna learn that how many vertex selected mesh got. should i do a algorithm like that 1) select all vertex of mesh and declare it to an array and lean size with size(); is there more simpler command to learn result faster. and other question is i try to learn position of a vertex and declare it to another objects translate xyz how can i do that? getattr pCube1.vtx[0:(\$vtxamount)]; all shows 0 0 0 0 0 0 0 0 0 0 why all positions of vertices are 0 even xyz? i scale ti but still same. i wanna learn global pos x yz of vertices can you help me about that. thank you
ph0t0n1st
12 December 2007, 01:08 PM
oh by the way i found why its 0 0 0. it gets position depends on pivot. how can i get global position?

Gravedigger
12 December 2007, 02:07 PM
hey photonist!
nice to see that you keep on scripting!

your idea would surely work but mel scripts are quite slow so your script executed with a high poly meshe could really knock your computer off i guess.

i would do it with the polyEvaluate command. do look it up in the maya documentary!
you can use it like this:

string \$selection[] = `ls -sl`;
int \$verts[] = `polyEvaluate -vertex \$selection[0]`;
print ("Vertex Count is: "+\$verts[0]+"\n");

yes its strange that i had to define \$verts as an array of integers. the documentation says that the return value was an integer but in fact it's an array with the size one. well shouldn't make you too much troubles.

ehm this command works with polygonal objects only! keep this in mind

hope this helped!

ph0t0n1st
12 December 2007, 02:30 PM
gravedigger thank you alot you help me to lean scripting
i checked maya documentation and i saw script editor. i played with vertices x yz at chanel box it gave me "setattr" and i thought getatr would work for me :D and umm i checked documentation, commands area there was huge poly functions i searched some but coudnt find what i wanted.
gravedigger thank you heartly.
i will try to figure out to get global position of a vertex but its hard :

Gravedigger
12 December 2007, 02:48 PM
you want to get the global position of a vertex? you may think that you need to calculate the position of the object and then adding up the position vectors or something like that but its really simple:

pointPosition -world pSphere1.vtx[0]; //returns the pointposition in world space coordinates
pointPosition -local pSphere1.vtx[0]; //returns the pointposition in local space coordinates

i used pSphere1 but you should replace this with your \$selection[0] or whatever you like.

CGTalk Moderation
12 December 2007, 02:48 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.

1