Introduction to Maya - Modeling Fundamentals Vol 1
This course will look at the fundamentals of modeling in Maya with an emphasis on creating good topology. We'll look at what makes a good model in Maya and why objects are modeled in the way they are.
# 1 06-11-2004 , 08:57 PM
Forlax's Avatar
Subscriber
Join Date: Aug 2003
Location: Middlesbrough, UK
Posts: 73

Vertex Positions in MEL commands

Does anybody know how to get the global position of a vertex on an object using mel scripting.

I tried this:

float $VtxPos[] = `polyMoveVertex -q -t $objName.vtx[0]`;

The script doesn't complete and seems to just hang.

I know this because the script should create a cone at the end of the script.

Come to think of it, I'm actually trying to find the centre of a face. My method is to get the three vertices of the face and average them.

Perhaps somebody knows how to do this and save me a job.

I assume objectCenter is for objects only. (I already tried it without sucess).

Thanks.

Forlax.

# 2 07-11-2004 , 03:10 AM
kbrown's Avatar
Moderator
Join Date: Sep 2002
Location: London, UK
Posts: 3,198
To get the vertex pos do this:

float $fVtxPos[] = `xform -q -ws -t ($sObjName + ".vtx[0]")`;

I think this would return all vertex positions associated to a face...

float $fVtxPos[] = `xform -q -ws -t ($sObjName + ".f[0]")`;

there might be an easier way for getting the face center. not sure...


Kari
- My Website
- My IMDB

Do a lot, Fail a lot and Learn a lot!
# 3 07-11-2004 , 11:37 AM
Forlax's Avatar
Subscriber
Join Date: Aug 2003
Location: Middlesbrough, UK
Posts: 73
This throws up a syntax error.

My $objName is of type string[], so I get the following error message.

// Error: Illegal operation "+" on data of type string[]. //

I assume in your code your objName was of type string.

What is the way around this?

Sorry I am a MEL newbie.

# 4 07-11-2004 , 01:19 PM
kbrown's Avatar
Moderator
Join Date: Sep 2002
Location: London, UK
Posts: 3,198
you're dealing with a string array (list of strings) so you need to supply the index as well. eg:

float $fVtxPos[] = `xform -q -ws -t ($sObjName[0] + ".vtx[0]")`;


Kari
- My Website
- My IMDB

Do a lot, Fail a lot and Learn a lot!
# 5 07-11-2004 , 01:50 PM
Forlax's Avatar
Subscriber
Join Date: Aug 2003
Location: Middlesbrough, UK
Posts: 73
Sorry.

I figured out my mistake the minute before you replied.

Thanks tho. I appreciate your help.

Thanks.

Forlax.

Posting Rules Forum Rules
You may not post new threads | You may not post replies | You may not post attachments | You may not edit your posts | BB code is On | Smilies are On | [IMG] code is On | HTML code is Off

Similar Threads