View Full Version : How to use MEL to get the current location of an edge?
Quoll 07-04-2004, 12:35 AM I have been trying to return the translate y and z values of an edge on a poly object, and I am having no luck. This is the code that is not working for me.
$firstEh = 'getAttr StairWedge.e[0] ty';
I've successfully used this to return an object's scale:
$firstEh = 'getAttr StairWedge.sy';
... but I can't quite make the syntax leap to get values for an edge. I've got 4 MEL books here with me and not one of them has an example of this!
Any help is greatly appreciated. Thank you!
|
|
mhovland
07-04-2004, 12:12 PM
What do you want to do with the position informations? I ask, because I'm not sure you can actually query the position of an edge. I mean, at what point along the edge are you going to query? The center point of the edge will change based on the length of the edge, right?
So maybe what you want to do is take your edge in question, use filterExpand to get the verts at either end of the edge, and query their values using either pointPosition or xform.
more info needed......
Quoll
07-07-2004, 10:47 PM
Thanks for the reply, and for the tip on the pointPostion. That is exactly the sort of thing I'm needing, I think.
What I'm trying to do is create an automated stair maker. I've got a MEL script that opens a window where a user can create a "positioning wedge" via a button. The user then places the wedge where they want the stairs to be created, and enters the number of steps wanted in a text field. So far, so good, and I've got the steps being created without problem. What I want to do is get some positional data from the wedge, specifically height and depth, and then use that to determine the amount of extrusion for each step.
I have hardcoded values working fine, and I have used pointPosition to get the x,y,z location of a point. (GREAT tip!) Could you tell me how to take those returned values and break them up so I can evaluate them against each other? Would I do that with an array?
I'm a little lost in MEL, as I've only written in ASP and a little JavaScript before, but I assume there is some way to just get the equivalent of a "myObject.myVertex.translateX"?
Thank you so much for your help.
mhovland
07-08-2004, 03:39 PM
pointPosition returns it's info into a float[3] array, so once you have the info returned you access it by grabbing it out of the array, like this:
//get what is selected
string $selected[] = `ls -sl -fl`;
//get the positions of the first member of the $selected array
float $pos[] = `pointPosition -w $selected[0]`;
//print each member of the position array
print ("X = " + $pos[0] + "\n");
print ("Y = " + $pos[1] + "\n");
print ("Z = " + $pos[2] + "\n");
Does that help? Let me know if you need more info.
Quoll
07-08-2004, 09:17 PM
Hey, thanks! That is exactly what I was needing! I've got my object sizing procedure working perfectly, and with this I was also able to add some cool extra functionality.
Thanks again so much, I really appreciate the help.
CGTalk Moderation
01-18-2006, 03: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-2012, Jelsoft Enterprises Ltd.