View Full Version : Average two vertices.
Hi Im a MEL ignoramus. Im taking a course in a couple of months so hopefully I'll know more then. In the meantime, and as a way to improve my knowledge...
What i need to do is find the average of x number of vertices (mostly just two). And then place something (maybe a locator ??) at this point, so as to be able to snap other things to this point.
I looked at the script editor when running merge vertices but i couldnt see anything here that might help me.
Thanks a bunch.
04-12-2006, 01:16 AM
You just need to get their position and add all of the vectors to get a total value. Then divide that value by the number of vectors you added together. That will give you the average (center point) of the group.
04-12-2006, 01:20 AM
string $selList = `ls -sl -flatten`;
if (size($selList) > 0)
vector $xyz = <<0, 0, 0>>;
for ($i in $selList)
float $pos = (`pointPosition -w $i`);
vector $xyzPos = <<$pos, $pos, $pos>>;
$xyz += $xyzPos;
vector $averagePos = $xyz / (size($selList));
float $x = $averagePos.x; float $y= $averagePos.y; float $z = $averagePos.z;
spaceLocator -p $x $y $z;
error ("select some verts");
04-12-2006, 02:16 AM
that was handy .i was just getting 'round to writing something similar .to place a joint in the center of a selection .john 's saved us both the bother
Bingo thanks John that works a treat. Kudos to you John...Kudos
Whilst im on a good wicket ..Do you know of any scripts that place a point / locator on the intersection of two lines based upon a specified axis plane?
Eg Select line 1 and then line 2 and then it will place a locator on the intersection. Generally the lines wont be on the same plane (ie intersecting in 3d space). So the locator would be projected through a nominated axis (eg xy) onto one of the lines (eg first selected).
04-12-2006, 03:30 AM
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-2014, Jelsoft Enterprises Ltd.