Setting vertices to X=0

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Display Modes
  04 April 2003
Setting vertices to X=0

Hi everybody,
I wrote a little mel script that is supposed to set the X Translation value of a selection of polyVertices to zero. I use this before I copy/mirror/combine/mergeVertices my symmetrical Poly Objects, the script works ok but as soon as I have more than a couple of vertices selected (maybe a dozen or so) it puts vertices on the same point which is not what it is supposed to do. It should simply get the Position of a given Vertex in an array and and set the x translation to 0. the other values(Y and Z ) should not be changed.
Has Somebody a clue what I do wrong ?
1. create/use a poly-object
2. select vertices
3. run the script

//Beginning of script

string $vertices[]=`ls -sl`;
string $vertex;

//loop over the selected vertices
for ($vertex in $vertices)
float $translates[];

//Get the translation values of the current vertex
$translates=`xform -q -t -ws $vertex`;

//Set X to 0 , keep the other values
xform -t 0 $translates[1] $translates[2] -ws $vertex;

clear $translates;
//end of script

  04 April 2003
chage the line
string $vertices[]=`ls -sl`;

string $vertices[]=`ls -sl -fl`;

and it should work properly.

  04 April 2003
now it works perfectly!
Thanks a million
  04 April 2003
is easiest use

scale -r -p 0 cm 0cm 0cm 0 1 1 ;

scale all de vertex you have select to 0 with the pivot in the x=0 plane
  04 April 2003
HI guys , I have been using a script from High end for quite some time to do this , but in light of your thread I though I might sugest a posiblity for your code.

A very useful tool I have used in miria is the mirror tool . You select a face around which mirroring occurs and then start to model. From that point onwards you will not be able to translate the joining vertices in the x direction only y and z.
Is there way to do this within maya?

thanks for any idea

  04 April 2003
Yo, larryvm, nice call!

kpalazov, I don`t think that there is a way to lock the translation of a vertex. For modelling it is often useful to click on the x-axis of your move tool while you keep >Strg<-key pressed so that it will keep translation on the YZ-plane (<Sorry, if you knew that one already). I use Artisan a lot and when I use the smooth option my nice edge for mirroring regularly gets messed up so I wrote my little mel script dumped it and now I use larryvms suggestion . It `s not the most sophisticated workflow, but it is ok. The Mirai tool sounds pretty cool too bad there isn`t something similar in Maya, or is there?
Since this what we are talking about is something that a lot (all?) modellers have to deal with, the Maya developers could spend some time improving this kind of workflow.
Anyway, a nice day to everyone
Buexe out
  04 April 2003
the quick way to snap the vertex to one position will be the keyframe. you can move, and only change the frame it will be in the initial place.
  04 April 2003
In Maya 4.5 you can go into :

Tool Settings / ( double click the move icon )
Move Snap Settings /
Retain Component Spacing.. Click OFF

and that will mean you can snap a selection to the grid.


Last edited by BigErn : 04 April 2003 at 02:45 PM.
  04 April 2003
Did I say there is something not possible in Maya? Of course a vertex can be locked in position, I wrote a little mel Script that takes a selection of vertices, than creates a group and connects the Translate X of the null to the vertices so they get the translation of the group. Now you can use Artisan model like crazy and those vertices won`t change their X-Value, unless you move the group. If you want the "constraint" to be off again, simply delete the group.
So here is the script:

//Select PolyVertices which you want to constrain to X=0//
//Powered by Buexe
string $vts_list[] =`ls -sl -fl`;
string $lockX =`group -empty`;
string $current;

for ($current in $vts_list)
string $lockX_tx = $lockX + ".tx";
string $buffer1[];
string $buffer2[];
string $buffer3[];

tokenize $current "[" $buffer1;
tokenize $buffer1[1] "]" $buffer2;
tokenize $current "." $buffer3;

string $vtx_tx = $buffer3[0] + ".pnts[" + $buffer2[0] + "].pntx";

connectAttr -f $lockX_tx $vtx_tx ;
rename $lockX Lock_X;
//End of script

This is just a quick hack but seems to work, I`m sure there are a lot of things that could be made nicer.

  05 May 2003
yeah, you might think you could just lock the componet translate attributes, but no, that only works under querky situations. so i use same solution as you, but find that there is something about the 0 index vert? it just doesnt like to be controlled like this. been meaning to ask alias about this...anybody got any clues?
  05 May 2003
Hi wrend, I read your post a couple of times and I have a hard time understanding what yu mean. What is the problem with the 0 index vert? And what are the quer(k)y situations? This script is supposed to help you when modelling in component mode or using Artisan, nothing else.
Maybe you can cast some light in my (mel) darkness
  01 January 2006
Thread automatically closed

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.
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
Thread Closed share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 10:57 AM.

Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.