View Full Version : Setting vertices to X=0
04-14-2003, 09:39 PM
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`;
//loop over the selected vertices
for ($vertex in $vertices)
//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 $translates -ws $vertex;
//end of script
chage the line
string $vertices=`ls -sl`;
string $vertices=`ls -sl -fl`;
and it should work properly.
04-14-2003, 11:04 PM
:thumbsup: now it works perfectly!
Thanks a million
04-17-2003, 12:22 PM
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-24-2003, 02:24 AM
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-24-2003, 08:22 AM
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 :cool:
04-24-2003, 01:20 PM
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-24-2003, 03:41 PM
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.
04-24-2003, 05:03 PM
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`;
for ($current in $vts_list)
string $lockX_tx = $lockX + ".tx";
tokenize $current "[" $buffer1;
tokenize $buffer1 "]" $buffer2;
tokenize $current "." $buffer3;
string $vtx_tx = $buffer3 + ".pnts[" + $buffer2 + "].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-02-2003, 04:01 PM
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-05-2003, 09:16 AM
Hi wrend, I read your post a couple of times and I have a hard time understanding what yóu 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-14-2006, 10:00 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.
vBulletin v3.0.5, Copyright ©2000-2015, Jelsoft Enterprises Ltd.