View Full Version : Length of an edge?
drossxyu 12152007, 11:46 PM Is there a command that would allow me to determine to length of an edge in maya units? Or perhaps someone could point me in the right direction... I'm looking to make a script that basically allows me to select an edge and it'll return the length immediately.
Thanks,
f


el diablo
12162007, 08:39 AM
you can convert it to a curve and do an arclen on the curve....el_diablo
having 2 points A and B, the distance between them is:
sqrt( (xAxB)^2 + (yAyB)^2 + (zAzB)^2 )
so, get the coords of the points forming the edge (`xform q ws tr` returns
them directly if you select an edge) and use the formula.
if you want to do it for an edge loop, you could do it the same way for
every edge, but i'm sure there are also faster, approximating, ways.
shi76a
12192007, 07:55 PM
edit
sorry, dubbleposting
shi76a
12192007, 08:09 PM
this ain't pretty but it does return an endgelength based upon two selected vertices....
note, i'm not a scripter so this scriptie's not realy efficient'n stuff
proc float getDistance() {
float $delta[];
float $v1[3];
float $v2[3];
string $vertices[];
$vertices = `filterExpand sm 31`;
vector $magVector;
float $distance;
if (`size $vertices` == 2) {
$v1 = `pointPosition $vertices[0]`;
$v2 = `pointPosition $vertices[1]`;
for ( $i = 0; $i < 3; $i++ ){
$delta[$i] = $v1[$i]  $v2[$i];
$magVector = $delta;
$distance = `mag $magVector`;
}
} else {
$distance = 0;
}
return $distance;
ewerybody
12202007, 11:22 AM
@el diablo: hehe :] good one!
@cpan: thats right!
@shi76a: you scripted this? mag to get the length is a good way too!!
look I rounded it up a little:
proc float getDistance()
{
string $vertices[] = ls("fl", polyListComponentConversion("tv"));
if (size($vertices) == 2)
{
float $v1[] = `pointPosition $vertices[0]`;
float $v2[] = `pointPosition $vertices[1]`;
return mag(<<$v1[0]  $v2[0], $v1[1]  $v2[1], $v1[2]  $v2[2]>>);
}
return 0;
}No need for all those variables. And you can just convert the selection to vertices ("tv"). Making you able to just select an edge and there you go.
shi76a
12222007, 06:52 PM
thanks for cleaning it up :) its much clearer now :)
cmogk
12242007, 05:52 PM
There's also an edge length HUD in the Bonus Tools.
animaxforever
12282007, 04:47 PM
thanx a lot guys...will try
CGTalk Moderation
12282007, 04:47 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 ©20002014, Jelsoft Enterprises Ltd.